Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where would noop be used in Ceylon

Tags:

ceylon

I am playing around with this beautiful language and saw a function called noop.

As the documentation says it's a void function that does nothing!!

So why would I use a function that does nothing? Is it for adding "Nop" in assembly (for pipeline etc) but then this would be too low-level wouldn't it?

like image 996
niceman Avatar asked Jul 24 '15 21:07

niceman


People also ask

Which country was known as Ceylon?

- WorldAtlas Which Country Was Known as Ceylon? Sri Lanka was formerly referred to as Ceylon when it was a British crown colony. Ceylon was a British crown colony that existed from 1815 to 1948 when it was granted independence and became an independent country within the Commonwealth of nations from 1948 to 1972.

Where does Ceylon get its cinnamon?

With its trading ports of Trincomalee and Colombo, the colony was one of the very few sources of cinnamon in the world. The spice was extremely valuable, and the British East India Company began to cultivate it from 1767, but Ceylon remained the main producer until the end of the 18th century

What type of government does Ceylon have?

The constitution of Ceylon created a parliamentary democracy with a bicameral legislature consisting of a Senate and a House of Representatives, with the popularly elected House indirectly naming the Senate. The head of state was the British monarch, represented in the country by the Governor General.

Is Ceylon's democracy facing new challenge in wake of strife?

^ "Ceylon's Democracy Faces New Test in Wake of Strife; Ceylon's Democracy Confronts New Challenge in Wake of Strife". The New York Times. 13 July 1958. Archived from the original on 22 July 2018. Retrieved 1 May 2010. ^ "Archived copy" (PDF).


2 Answers

noop() can take the place of any void (or Anything returning) function. So it's useful to use as a value if you are calling a function or creating an object that requires you to pass in an event handler or callback function, but you aren't interested in responding to the event.

like image 87
John Vasileff Avatar answered Sep 28 '22 00:09

John Vasileff


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

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

Or:

void foo(Anything(Integer) bar = noop) {}
like image 44
Gavin King Avatar answered Sep 28 '22 02:09

Gavin King