Click here to load reader
Upload
gourav-tiwari
View
268
Download
1
Embed Size (px)
DESCRIPTION
Some unusual and useful tips and tricks I found in Ruby 2.0 and 1.9.3
Citation preview
Ruby 2.0Tips and tricks along with 1.9.3
Keyword arguments
splat operator
Convert to hash
#to_h
Works on:Struct, ENV, Hash, NilClass, OpenStruct
Doesn’t work on:Array, String, etc
Convert to hash
Convert to hash
Support to Gemfile
gem install --file Gemfile (no Gemfile.lock needed)
gem install --file Gemfile --install-dir vendor/gem
inspect: odd behavior is gone!
to_s will not be a hook for inspect!
define_method
How do you un-define a method?
remove_method
MISC
utf-8 default support_%i
More to come…