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?
- 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.
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
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.
^ "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).
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.
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) {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With