Ruby2.0 and 1.9.3 tips and tricks

320
-1

Published on

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

Published in: Technology, Education
2 Comments
0 Likes
Statistics
Notes
  • @doel, Absolutely correct Doel, now define_method can be used in main context, outside the scope of class as well.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • great post Gourav, thanks for sharing :) Just wanted to understand, for the define_method, we don't have to declare it within a class in ruby 2.0 unlike ruby 1.9, is the understanding correct?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

No Downloads
Views
Total Views
320
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
2
Likes
0
Embeds 0
No embeds

No notes for slide

Ruby2.0 and 1.9.3 tips and tricks

  1. 1. Ruby 2.0 Tips and tricks along with 1.9.3
  2. 2. Keyword arguments
  3. 3. splat operator
  4. 4. Convert to hash #to_h Works on: Struct, ENV, Hash, NilClass, OpenStruct Doesn’t work on: Array, String, etc
  5. 5. Convert to hash
  6. 6. Convert to hash
  7. 7. Support to Gemfile gem install --file Gemfile (no Gemfile.lock needed) gem install --file Gemfile --install-dir vendor/gem
  8. 8. inspect: odd behavior is gone! to_s will not be a hook for inspect!
  9. 9. define_method
  10. 10. How do you un-define a method? remove_method
  11. 11. MISC utf-8 default support _ %i
  12. 12. More to come…
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×