File tree Expand file tree Collapse file tree 3 files changed +14
-21
lines changed
Expand file tree Collapse file tree 3 files changed +14
-21
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,9 @@ Changes:
103103 * Redefine ` String#lchomp ` / ` #lchomp! ` as aliases for ` delete_prefix ` / ` delete_prefix! ` .
104104 * Rename ` Time#trunc ` to ` Time#floor_to ` (parallels ` Time#round_to ` ; avoids confusion
105105 with Ruby's ` Time#floor ` which takes sub-second digit precision). ` trunc ` deprecated.
106+ * Fix ` Binding#[] ` and ` #[]= ` to use ` local_variable_get ` /` local_variable_set `
107+ (broken since Ruby 1.9; now works again).
108+ * Deprecate ` Binding#self ` (use ` Binding#receiver ` , adopted by Ruby in 2.6).
106109 * Deprecate ` File.null ` (use ` File::NULL ` constant, Ruby 1.9.3+).
107110 * Deprecate ` File.read_binary ` (use ` File.binread ` , Ruby 1.9.3+).
108111 * Fix dead requires for removed ` kernel/singleton_class ` in Proc and Kernel.
Original file line number Diff line number Diff line change 11class Binding
22
3- # Returns the value of some variable.
3+ # Returns the value of a local variable.
44 #
55 # a = 2
6- # binding["a" ] #=> 2
6+ # binding[:a ] #=> 2
77 #
8- def []( x )
9- eval ( x . to_s )
8+ def []( name )
9+ local_variable_get ( name . to_sym )
1010 end
1111
1212 # Set the value of a local variable.
1313 #
14- # binding["a" ] = 4
14+ # binding[:a ] = 4
1515 # a #=> 4
1616 #
17- # @deprecated No longer wortks in Ruby 1.9+.
18- #
19- # @see Binding#with for an alternative.
20- def []=( l , v )
21- eval ( "lambda {|v| #{ l } = v}" ) . call ( v )
17+ def []=( name , value )
18+ local_variable_set ( name . to_sym , value )
2219 end
2320
2421end
25-
Original file line number Diff line number Diff line change 11class Binding
22
3- # This is already defined by Rubinius:
4- # Kernel.eval('Rubinius::VariableScope.current.self', self)
5- unless method_defined? ( :self )
6-
7- # Returns self of the binding's context.
8- def self
9- eval ( 'self' )
10- end
11-
3+ # @deprecated Use Binding#receiver instead (built-in since Ruby 2.6).
4+ def self
5+ warn "Binding#self is deprecated. Use Binding#receiver instead." , uplevel : 1
6+ receiver
127 end
138
149end
15-
You can’t perform that action at this time.
0 commit comments