# All\_symbols array in irb

**URL:** <https://rubytalk.org/t/all-symbols-array-in-irb/69206>\
**Category:** ruby-talk\
**Created:** [23 February 2014 00:56 UTC](https://rubytalk.org/t/all-symbols-array-in-irb/69206 "2014-02-23T00:56:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gvim](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@gvim](https://rubytalk.org/u/gvim)\
**Post date:** [23 February 2014 00:56 UTC](https://rubytalk.org/t/all-symbols-array-in-irb/69206/1 "2014-02-23T00:56:58Z")

</div>

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.

gvim

---

<div class="post-metadata">

**Author:** ![Ryan\_Davis1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/ryan_davis1/32/1848_2.png) [@Ryan\_Davis1](https://rubytalk.org/u/Ryan_Davis1)\
**Post date:** [23 February 2014 01:52 UTC](https://rubytalk.org/t/all-symbols-array-in-irb/69206/2 "2014-02-23T01:52:33Z")

</div>

> 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:

10004 % ruby -e 'p Symbol.all\_symbols.sort.grep(/^a/).first 5'  
[:a, :abort, :abort\_on\_exception, :abort\_on\_exception=, :abs]

> **···**
>
> On Feb 22, 2014, at 16:56, gvim \<gvimrc@gmail.com\> wrote:

---

<div class="post-metadata">

**Author:** ![Mike\_Stok1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/mike_stok1/32/2065_2.png) [@Mike\_Stok1](https://rubytalk.org/u/Mike_Stok1)\
**Post date:** [23 February 2014 03:36 UTC](https://rubytalk.org/t/all-symbols-array-in-irb/69206/3 "2014-02-23T03:36:58Z")

</div>

Did you check to see if :a and :b already existed?

~ ∙ pry  
[1] pry(main)\> Symbol.all\_symbols.size  
=\> 14199  
[2] pry(main)\> Symbol.all\_symbols.include? :a  
=\> true  
[3] pry(main)\> Symbol.all\_symbols.size  
=\> 14199  
[4] pry(main)\> an\_unlikely\_name\_to\_see\_if\_we\_get\_a\_new\_symbol = 5  
=\> 5  
[5] pry(main)\> Symbol.all\_symbols.size  
=\> 14200  
[6] pry(main)\> RUBY\_VERSION  
=\> "2.1.0"

> **···**
>
> 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:
> > 
> > > > 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.
> > 
> > gvim
> 
> --
> 
> Mike Stok \<mike@stok.ca\>  
> [http://www.stok.ca/~mike/](http://www.stok.ca/~mike/)
> 
> The "`Stok' disclaimers" apply.

---

<div class="post-metadata">

**Author:** ![gvim](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@gvim](https://rubytalk.org/u/gvim)\
**Post date:** [23 February 2014 02:12 UTC](https://rubytalk.org/t/all-symbols-array-in-irb/69206/4 "2014-02-23T02:12:12Z")

</div>

> 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:
> 
> 10004 % ruby -e 'p Symbol.all\_symbols.sort.grep(/^a/).first 5'  
> [:a, :abort, :abort\_on\_exception, :abort\_on\_exception=, :abs]

So irb is different? Might explain why I also get this:

> > require 'date'

=\> false

> > require 'time'

=\> true

gvim

> **···**
>
> On 23/02/2014 01:52, Ryan Davis wrote:

---

<div class="post-metadata">

**Author:** ![Ryan\_Davis1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/ryan_davis1/32/1848_2.png) [@Ryan\_Davis1](https://rubytalk.org/u/Ryan_Davis1)\
**Post date:** [23 February 2014 02:41 UTC](https://rubytalk.org/t/all-symbols-array-in-irb/69206/5 "2014-02-23T02:41:41Z")

</div>

I wouldn't call it different... but IRB loads code. A lot of it.

> **···**
>
> On Feb 22, 2014, at 18:12, gvim \<gvimrc@gmail.com\> wrote:
> 
> > On 23/02/2014 01:52, Ryan Davis wrote:
> > 
> > > 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:
> > > 
> > > 10004 % ruby -e 'p Symbol.all\_symbols.sort.grep(/^a/).first 5'  
> > > [:a, :abort, :abort\_on\_exception, :abort\_on\_exception=, :abs]
> > 
> > So irb is different? Might explain why I also get this:
> > 
> > > > require 'date'
> > 
> > =\> false
> > 
> > > > require 'time'
> > 
> > =\> true
