Skip to content

Instantly share code, notes, and snippets.

@Marahin
Created October 24, 2018 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marahin/3a283ff6667ec21a6d874d1e25d072e4 to your computer and use it in GitHub Desktop.
Save Marahin/3a283ff6667ec21a6d874d1e25d072e4 to your computer and use it in GitHub Desktop.
Frozen things are frozen
["john", "alice", "philip"]
=> ["john", "alice", "philip"]
arr.map!(&:freeze).freeze
=> ["john", "alice", "philip"]
arr.map(&:downcase!)
FrozenError: can't modify frozen String
from (pry):3:in `downcase!'
arr.map!(&:downcase)
FrozenError: can't modify frozen Array
from (pry):4:in `map!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment