Anonymous function: Difference between revisions

Content deleted Content added
Visual Prolog: fix syntaxhighlight error
Ruby: fix syntaxhighlight error
Line 1,509:
Ruby supports anonymous functions by using a syntactical structure called ''block''. There are two data types for blocks in Ruby. <code>Proc</code>s behave similarly to [[Closure (computer programming)|closures]], whereas <code>lambda</code>s behave more analogous to an anonymous function.<ref name=":10">{{cite web|url=http://www.reactive.io/tips/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/ |title=Understanding Ruby Blocks, Procs and Lambdas |last=Sosinski |first=Robert |publisher=Reactive.IO |date=2008-12-21 |access-date=2014-05-30 |url-status=dead |archive-url=https://web.archive.org/web/20140531123646/http://www.reactive.io/tips/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/ |archive-date=2014-05-31 }}</ref> When passed to a method, a block is converted into a Proc in some circumstances.
 
<syntaxhighlight lang="irbruby">
# Example 1:
# Purely anonymous functions using blocks.