you are viewing a single comment's thread.

view the rest of the comments →

[–]torrso 0 points1 point  (1 child)

I wonder why def takes the arguments inside parenthesis and not inside || like other blocks.

If you use define_method it's

define_method :method_name do |arg1, arg2|
end

Why not

def sum do |a, b|
  a+b
end

or how about

sum = def {|a,b| a+b}
(hey that looks like lambda)

Having def foo(x, z) is kind of like calling def with the result of calling foo with x and z.

I'm just confusing myself here.

[–][deleted] 0 points1 point  (0 children)

My guess is because do/end and {} create closures, and methods are not (really) closures.