Ruby Curly Brackets for "set" value -


what's difference between these 2 variations in ruby

set: example1, "/random/string" 

and

set: example2, -> {"random/string"} 

do both have same effect?

although superficially similar they're 2 different things.

the first simple string, second proc returns string. many methods in ruby world take both, proc version way of deferring evaluation of until if , when it's needed.

the -> { ... } notation shorthand lambda { ... }, it's called stabby-lambda operator.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -