Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Intro To Ruby

2,301 views

Published on

These are the slides from the Intro To Ruby talk I gave at Tampa/Orlando day of ruby

Published in: Technology, Education
  • Be the first to comment

Intro To Ruby

  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

×