Skip to content

Instantly share code, notes, and snippets.

@RocketPuppy
Last active August 29, 2015 14:04
Show Gist options
  • Save RocketPuppy/3e3dda6c0ecb2d1ed326 to your computer and use it in GitHub Desktop.
Save RocketPuppy/3e3dda6c0ecb2d1ed326 to your computer and use it in GitHub Desktop.
~$ irb
irb(main):001:0> FOO = 'baz'
=> "baz"
irb(main):002:0> FOO = 'bar'
(irb):2: warning: already initialized constant FOO
(irb):1: warning: previous definition of FOO was here
=> "bar"
irb(main):003:0> FOO
=> "bar"
irb(main):004:0> FOO.upcase
=> "BAR"
irb(main):005:0> FOO
=> "bar"
irb(main):006:0> FOO << 'foo"
irb(main):007:0' '
=> "barfoo\"\n"
irb(main):008:0> FOO
=> "barfoo\"\n"
irb(main):009:0> FOO = { blah: 'ole!' }
(irb):9: warning: already initialized constant FOO
(irb):2: warning: previous definition of FOO was here
=> {:blah=>"ole!"}
irb(main):010:0> FOO
=> {:blah=>"ole!"}
irb(main):011:0> FOO[:blah] = 5
=> 5
irb(main):012:0> FOO
=> {:blah=>5}
irb(main):013:0>
EDIT: Just occurred to me to add a way to avoid this
~$ irb
irb(main):001:0> def foo
irb(main):002:1> 'baz'
irb(main):003:1> end
=> nil
irb(main):004:0> foo
=> "baz"
irb(main):005:0> foo << 'bar'
=> "bazbar"
irb(main):006:0> foo
=> "baz"
irb(main):007:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment