so i'm trying to work out how the sym.to_proc method works, supposedly any object that implements to_proc has a shorthand which is simply an & before the object, but this shorthand's behavior seems erratic:
this works
irb(main):022:0> p = :to_s.to_proc
=> #<Proc:0x00000000056c33b0(&:to_s)>
but this doesn't
irb(main):023:0> p = &:to_s
Traceback (most recent call last):
3: from X:/Ruby26-x64/bin/irb.cmd:31:in `<main>'
2: from X:/Ruby26-x64/bin/irb.cmd:31:in `load'
1: from X:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
SyntaxError ((irb):23: syntax error, unexpected &)
p = &:to_s
^
and now the other way around, this works
irb(main):024:0> (0..10).map &:to_s
=> ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
but this doesn't!
irb(main):025:0> (0..10).map(:to_s.to_proc)
Traceback (most recent call last):
5: from X:/Ruby26-x64/bin/irb.cmd:31:in `<main>'
4: from X:/Ruby26-x64/bin/irb.cmd:31:in `load'
3: from X:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
2: from (irb):25
1: from (irb):25:in `map'
ArgumentError (wrong number of arguments (given 1, expected 0))
these errors don't seem to make sense, i'm really at a loss here.