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
Post a Comment