Skip to content

Instantly share code, notes, and snippets.

@bbl
Last active November 14, 2017 15:16
Show Gist options
  • Save bbl/d951908f6a9dc441dc0b2b50b3d02c58 to your computer and use it in GitHub Desktop.
Save bbl/d951908f6a9dc441dc0b2b50b3d02c58 to your computer and use it in GitHub Desktop.
List of some weirdness and gotchas

Ruby

  1. Outside ENV strings are frozen:

example.rb:

ENV['foo'].strip!

Run:

foo='bar' ruby example.rb 
`strip!': can't modify frozen String (RuntimeError)
  1. Assigning anything but String to ENV produces TypeError
ENV['foo'] = :bar
# => `[]=': no implicit conversion of Symbol into String (TypeError)

ENV['foo'] = 5
# => `[]=': no implicit conversion of Fixnum into String (TypeError)

ENV['foo'] = {}
# => `[]=': no implicit conversion of Hash into String (TypeError)
 

Chef

  1. Logging true/false:
Chef::Log.warn(true)
=> WARN: true
Chef::Log.warn(false)
=> WARN: nil # Gotcha!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment