Hi,
I understand that
Synth(“blahblah”);
is equivalent to
Synth.new(“blahblah”), so I figure that .new is this object’s default
method. How can I find out about default methods for objects in general?
Thanks!
Hi,
I understand that
Synth(“blahblah”);
is equivalent to
Synth.new(“blahblah”), so I figure that .new is this object’s default
method. How can I find out about default methods for objects in general?
Thanks!
Thanks Paul,
now I understand that there are no default methods but
Something(1,2) is a shortcut for Something.new(1,2)
much appreciated!
P
I think that somewhere, new
might be called a “default method selector” for literal class names.
There’s also value
for instances:
f = { |n| n.rand };
f.value(5); // receiver = f, method = value, argument = 5
f.(5); // same
The dot is necessary to distinguish this from “function call syntax” where f(5)
would try to call a method f on the receiver 5. The dot isn’t necessary for literal classes because those are already distinguished by the uppercase keyword.
hjh