12

Click here to load reader

Ruby2.0 and 1.9.3 tips and tricks

Embed Size (px)

DESCRIPTION

Some unusual and useful tips and tricks I found in Ruby 2.0 and 1.9.3

Citation preview

Page 1: Ruby2.0 and 1.9.3 tips and tricks

Ruby 2.0Tips and tricks along with 1.9.3

Page 2: Ruby2.0 and 1.9.3 tips and tricks

Keyword arguments

Page 3: Ruby2.0 and 1.9.3 tips and tricks

splat operator

Page 4: Ruby2.0 and 1.9.3 tips and tricks

Convert to hash

#to_h

Works on:Struct, ENV, Hash, NilClass, OpenStruct

Doesn’t work on:Array, String, etc

Page 5: Ruby2.0 and 1.9.3 tips and tricks

Convert to hash

Page 6: Ruby2.0 and 1.9.3 tips and tricks

Convert to hash

Page 7: Ruby2.0 and 1.9.3 tips and tricks

Support to Gemfile

gem install --file Gemfile (no Gemfile.lock needed)

gem install --file Gemfile --install-dir vendor/gem

Page 8: Ruby2.0 and 1.9.3 tips and tricks

inspect: odd behavior is gone!

to_s will not be a hook for inspect!

Page 9: Ruby2.0 and 1.9.3 tips and tricks

define_method

Page 10: Ruby2.0 and 1.9.3 tips and tricks

How do you un-define a method?

remove_method

Page 11: Ruby2.0 and 1.9.3 tips and tricks

MISC

utf-8 default support_%i

Page 12: Ruby2.0 and 1.9.3 tips and tricks

More to come…