Skip to content

Instantly share code, notes, and snippets.

@olauzon
Created May 11, 2012 19:40
Show Gist options
  • Save olauzon/2661980 to your computer and use it in GitHub Desktop.
Save olauzon/2661980 to your computer and use it in GitHub Desktop.
Ruby WAT
# 1.8.7
[1, 2, 3].to_s
# => "123"
# 1.9.3p194
[1, 2, 3].to_s
# => "[1, 2, 3]" # WAT?
# `Array#to_s` is an alias to `Array#inspect`
[1, 2, 3].join.to_s
# => "123"
[nil, nil, nil].to_s
# => "[nil, nil, nil]"
[nil, nil, nil].inspect
# => "[nil, nil, nil]"
nil.to_s
# => ""
nil.inspect
# => "nil"
# Can't expect `#inspect` and `#to_s` to behave identically
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment