Where could be used in Ceylon

I play with this beautiful language and see a function called noop.

As the documentation says, this is a void function that does nothing !!

So why should I use a function that does nothing? This is for adding "Nop" to the assembly (for the pipeline, etc.), but then it will be too low level, right?

+5
source share
2 answers

noop() can replace any void (or Anything return) function. Therefore, it is useful to use as a value if you call a function or create an object that requires you to pass an event handler or a callback function, but you are not interested in responding to the event.

+8
source

noop() also useful as the default value for an optional function parameter, for example:

 void foo(void bar(Integer i) => noop(i)) {} 

Or:

 void foo(Anything(Integer) bar = noop) {} 
+7
source

All Articles