Skip to content

Instantly share code, notes, and snippets.

@keldin-coding
Created June 28, 2021 23:15
Show Gist options
  • Save keldin-coding/600e27ed898f8ff71f1f23ffc7493fa2 to your computer and use it in GitHub Desktop.
Save keldin-coding/600e27ed898f8ff71f1f23ffc7493fa2 to your computer and use it in GitHub Desktop.
# My least favorite valid Ruby code
"abc" "xyz"
# => "abcxyz"
# Truly cursed reminder that whitepsace doesn't matter for method invocation
# and that ary[index] syntax is just a fancy way to do ary.[](index)
[1] [2]
# => nil
foo = "abc"
foo. chars
# => ["a", "b", "c"]
foo .chars
# => ["a", "b", "c"]
foo . chars
# => ["a", "b", "c"]
[1] .[](0)
# => nil
[1, 2, 3] [0, 2]
# => [1, 2]
[1, 2, 3] [0, 1, 2]
# => Argument Error
ary = [1, 2, 3]
ary [1]
# => 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment