Skip to content

Instantly share code, notes, and snippets.

@agross
Created February 9, 2012 21:53
Show Gist options
  • Save agross/1783598 to your computer and use it in GitHub Desktop.
Save agross/1783598 to your computer and use it in GitHub Desktop.
Trying to initialize a hash with a value from a another, should fail if the other hash doesn't contain the key
hsh = { :key => other_hsh[:foo] or raise "No value for 'foo'!" }
@agross
Copy link
Author

agross commented Feb 9, 2012

Possible application in Haml:

%meta{ :name => "description", :content => @item[:description] or raise "No metadata description for #{@item.identifier}"  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment