Skip to content

Instantly share code, notes, and snippets.

@envex
Created May 26, 2010 14:37
Show Gist options
  • Save envex/414561 to your computer and use it in GitHub Desktop.
Save envex/414561 to your computer and use it in GitHub Desktop.
chars = [*" ".."~"]
charlist = nil
chars.each do |char|
charlist << "#{char},"
end
puts charlist
#this is returning
#char_loop.rb:6:in `block in <main>': undefined method `<<' for nil:NilClass (NoMethodError)
# from char_loop.rb:5:in `each'
# from char_loop.rb:5:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment