Software Development
Pages
Home
About
Contact
Wednesday, August 29, 2012
Eliminating if else statement using Blocks in Ruby
def foo(a)
if a == 1
yield
else
42
end
end
The above method customizes by using a block like this:
result = foo(1) do
98
end
p result
Newer Post
Older Post
Home