Weird Ruby: Positive and Negative Strings
metaredux.com
metaredux.com
Edit: Removed incorrect information.
unary * is the splat operator. While it tries to coerce arguments to an array, consider that this:
x,y,z = *(1..3),42
gives x=1,y=2,z=3, while: x,y,z = (1..3).to_a, 42
gives x=[1,2,3], y=42, z= nil
'&' meanwhile passes a Proc as the anonymous block to a method. E.g.: def foo; yield; end
pr = proc { puts "here" }
foo(&pr) # is equivalent to foo { puts "here" }
It too will try to coerce arguments to a proc by calling '#to_proc' on objects that responds to it, but 'to_proc' just returns a Proc (or should), it does not in itself convert a Proc to a default block. 'to_proc' has other uses - proc's can be passed around in all kinds of other situations too.