Intro To Ruby

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    4 Favorites

    Intro To Ruby - Presentation Transcript

    1. Corey Haines, Journeyman Developer Ruby It really is Love Saturday, May 30, 2009
    2. About Saturday, May 30, 2009
    3. Not About Convincing You To Use Ruby Saturday, May 30, 2009
    4. About Things I love in Ruby duck-typing open classes (almost) everything is executable ruby code Saturday, May 30, 2009
    5. Should You Learn Ruby? Saturday, May 30, 2009
    6. Corey Haines Journeyman Developer That’s Me! www.coreyhaines.com coreyhaines@gmail.com Saturday, May 30, 2009
    7. On To Ruby Saturday, May 30, 2009
    8. “...trying to make Ruby natural, not simple.” - Yukihiro Matsumoto “Matz” image courtesy Jim Lindley on flickr Saturday, May 30, 2009
    9. Qualities Simple Syntax Object-Oriented Duck-Typing Blocks Open Classes Saturday, May 30, 2009
    10. Qualities Simple Syntax Object-Oriented Duck-Typing Blocks Open Classes Saturday, May 30, 2009
    11. Initializers arr = [1, 6, 2, 3, 5] arr2 = [“Element”, “Another one”] lookup = { :ruby => “love”, :c_sharp => “good too”, :python => “cool” } Saturday, May 30, 2009
    12. Classes class Rectangle attr_accessor :width, :height def initialize(width, height) self.width = width self.height = height end def area width * height end end Saturday, May 30, 2009
    13. >> r = Rectangle.new(5, 20) => #<Rectangle:0x3691d8 @width=5, @height=20> >> r.area => 100 Saturday, May 30, 2009
    14. Qualities Simple Syntax Object-Oriented Duck-Typing Blocks Open Classes Saturday, May 30, 2009
    15. Everything is an object >> 9.succ => 10 >> 9.nil? => false >> 9.between? 8, 10 => true >> 9.class => Fixnum Saturday, May 30, 2009
    16. No Really >> 9.succ => 10 >> 9.nil? => false >> 9.between? 8, 10 => true Wha? >> 9.class => Fixnum >> Fixnum.class => Class Saturday, May 30, 2009
    17. Ever written something like this? public void MakeItQuack<T>(T quacker) where T : ICanQuack { quacker.Quack(); } Saturday, May 30, 2009
    18. Really Wanted public void MakeItQuack<T>(T quacker) where T can quack { quacker.quack(); } Saturday, May 30, 2009
    19. Qualities Simple Syntax Object-Oriented Duck-Typing Blocks Open Classes Saturday, May 30, 2009
    20. No, not that kind Saturday, May 30, 2009
    21. Duck-Typing Walks like a duck Quacks like a duck Must be a duck? Saturday, May 30, 2009
    22. Well, no But, we can interact with it like a duck! And Pretend! Saturday, May 30, 2009
    23. def make_it_quack(quacker) quacker.quack(); end Saturday, May 30, 2009
    24. Type != Class Behavior/Interaction-Orientation Saturday, May 30, 2009
    25. Qualities Simple Syntax Object-Oriented Duck-Typing Blocks Open Classes Saturday, May 30, 2009
    26. Blocks a = [5, 7, 10, 24] a.each do |num| puts num end b = a.map do |num| num * 2 end puts b.inspect Saturday, May 30, 2009
    27. Accepting Blocks def five_times yield 1 yield 2 yield 3 yield 4 yield 5 end five_times do |num| puts num end Saturday, May 30, 2009
    28. Accepting Blocks def five_times(&block) block.call(1) block.call(2) block.call(3) block.call(4) block.call(5) end five_times do |num| puts num end Saturday, May 30, 2009
    29. Qualities Simple Syntax Object-Oriented Duck-Typing Blocks Open Classes Saturday, May 30, 2009
    30. Open Classes Say goodbye to sealed/virtual/override/argh Saturday, May 30, 2009
    31. def convert(to_convert) return nil if to_convert.nil? return to_convert if to_convert.empty? do_conversion(to_convert) end Saturday, May 30, 2009
    32. As You Wish class NilClass def empty? true end end Saturday, May 30, 2009
    33. def convert(to_convert) return to_convert if to_convert.empty? do_conversion(to_convert) end Saturday, May 30, 2009
    34. Setting Time current_time = 17 Saturday, May 30, 2009
    35. write the code you wish you had current_time = 5.pm Saturday, May 30, 2009
    36. Then get it working class Fixnum def pm self + 12 end end Saturday, May 30, 2009
    37. Type != Class (redux) a = “coreyhaines@gmail.com;me@coreyhaines.com” Saturday, May 30, 2009
    38. Type != Class (redux redux) a = “coreyhaines@gmail.com;me@coreyhaines.com” a.extend(EmailAddressList) puts a.email_addresses.inspect a.each_address do |address| Mailer.send_email_to(address) end Saturday, May 30, 2009
    39. Remember With great power comes great responsibility Saturday, May 30, 2009
    40. Qualities Simple Syntax Object-Oriented Duck-Typing Blocks Open Classes Saturday, May 30, 2009
    41. Qualities Awesomeness! Simple Syntax Object-Oriented Duck-Typing Blocks Open Classes Saturday, May 30, 2009
    42. Method Missing Saturday, May 30, 2009
    43. Examples Builder Saturday, May 30, 2009
    44. Mixins Saturday, May 30, 2009
    45. Type != Class Saturday, May 30, 2009
    46. Examples Email Addresses Saturday, May 30, 2009
    47. defining methods Saturday, May 30, 2009
    48. Examples Email Addresses Saturday, May 30, 2009
    SlideShare Zeitgeist 2009

    + coreyhainescoreyhaines Nominate

    custom

    803 views, 4 favs, 3 embeds more stats

    These are the slides from the Intro To Ruby talk I more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 803
      • 733 on SlideShare
      • 70 from embeds
    • Comments 0
    • Favorites 4
    • Downloads 0
    Most viewed embeds
    • 68 views on http://programmingtour.blogspot.com
    • 1 views on http://static.slidesharecdn.com
    • 1 views on http://www.slideshare.net

    more

    All embeds
    • 68 views on http://programmingtour.blogspot.com
    • 1 views on http://static.slidesharecdn.com
    • 1 views on http://www.slideshare.net

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories