callstack - Ruby: method lookup in an outer frame -
I am trying to clone that F # people call "forward pipe" operator with Ruby and some Partial breakthrough was achieved.
I am stuck in the previous example (9). The result is
== Example 1 == 128 == Example 2 == [20, 40, 60, 80, 100] == Example 3 == # & lt; Proc: 0x000000022652d0 @ / Fsharp-forward-pipe.rb: 28 & gt; [20, 40, 60, 80, 100] == Example 4 == # & lt; Proc: 0x00000002265050 @. / Fsharp-forward-pipe.rb: 31 (lambda) & gt; [20, 40, 60, 80, 100] == Example 5 == # & lt; Proc: 0x00000002264dd0 @ / Fsharp-forward-pipe.rb: 34 (lambda) & gt; [20, 40, 60, 80, 100] == Example 6 == # & lt; Method: Object (Kernel) # puts & gt; [20, 40, 60, 80, 100] == Example 7 ==: puts # & lt; Method: String (Kernel) # puts & gt; [20, 40, 60, 80, 100] == Example 8 == # & lt; Method: Foo # Bar & gt; 10: [20, 40, 60, 80, 100] == Example 9 ==: bar ./fsharp-forward-pipe.rb:12:in `method ': Undefined method' bar 'for' class' (name Error) ./fsharp-forward-pipe.rb:12:in` & gt; & Gt; 'From ./fsharp-forward-pipe.rb:57:in' quux 'to ./fsharp-forward-pipe.rb:63:in `& lt; Main & gt; '
That is, if I change method (: quux)
for the beauty of notation: : quux
and And gt; & Gt;
The operators resolve this in some method, instead of the caller frame object # & gt; & Gt; Actually even the 7th example faced the same problem, but
: puts
to string # puts / <> Code was solved, which agreed with my desired method,
Kernel # puts it
.
Is it possible to specify the frame in which any symbol is solved in a method?
Comments
Post a Comment