RCR 296: Destructive methods return self

C

Csaba Henk

Hm, I'm not sure if the support has already been added to def, but the
following ought to work:

x(name: "Foobar", age: 100)

def x *a
a
end

x(name: "Foobar", age: 100) # => [{:name=>"Foobar", :age=>100}]
x:)name => "Foobar", :age => 100) # => [{:name=>"Foobar", :age=>100}]

Yep, it's not a big deal. This is just a not too useful syntax sugar
(those colons before the keys were not uncomfortable at all).

But, as you say, it's not finished yet. I hope at the end we get some
reflection (Method#has_keyword?:)sym) or something along this line)
otherwise it's just hype.

Csaba
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top