According to "The Well Grounded Rubyist" 2nd edition the following should increment the size of the all_symbols array by 2 for variables a and b but it doesn't:
According to "The Well Grounded Rubyist" 2nd edition the following should increment the size of the all_symbols array by 2 for variables a and b but it doesn't:
Symbol.all_symbols.size
=> 3812
a = 1
=> 1
Symbol.all_symbols.size
=> 3812
b = 2
=> 2
Symbol.all_symbols.size
=> 3812
Symbol.all_symbols.include? :a
=> true
Symbol.all_symbols.include? :b
=> true
Symbol.all_symbols.size
=> 3812
I'm running Ruby version 2.1.0 on Mac OS X.
That's certainly true _in_theory_ but you're running irb, which is a complicated mess:
Symbol.all_symbols.sort.grep(/^a/).first 5
=> [:a, :a1, :a2, :abort, :abort_on_exception]
but even without irb, there's plenty of symbols defined:
On Feb 22, 2014, at 7:56 PM, gvim <gvimrc@gmail.com> wrote:
According to "The Well Grounded Rubyist" 2nd edition the following should increment the size of the all_symbols array by 2 for variables a and b but it doesn't: