auto assign arguments?

D

Daniel Berger

Hi --



That was proposed as an RCR and rejected; see
http://oldrcrs.rubypal.com/rejected.html#rcr3

Hm, no reason given, but one of the things I don't like about it is the
change in syntax it required. With the advent of keyword parameters
(right?), and the ability to get the parameter names from within a
method, this should be trivial to implement on our own in 1.9 if Matz
doesn't want it as the default behavior.

Dan
 
G

Gregory Brown

Why the class' instance variables? That doesn't fit with the current pattern:

class C
def initialize(v = nil)
@default = v
end
def otherdefault
42
end
def ultimate(v = @default || otherdefault)
v
end
end
C.new.ultimate #=> 42
C.new(54).ultimate #=> 54

Hmm... you're right. I can see that now (and have used it!)

Still, I do think the RCR would make things more messy, but would be
all for something in core or the standard library that could allow me
to enable the behavior on the fly for any given class.

(Though I'm not strongly invested one way or the other)
 
P

Paulo Köch

Ok, this isn't quite an answer, but why not using editor macros?

Just a thought, don't flame me.

Paulo Jorge Duarte K=F6ch
(e-mail address removed)
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top