SlideShare a Scribd company logo
1 of 48
Corey Haines, Journeyman Developer




                                                       Ruby
                                                         It really is Love




Saturday, May 30, 2009
About




Saturday, May 30, 2009
Not About


                         Convincing You To Use Ruby




Saturday, May 30, 2009
About


                         Things I love in Ruby
                                         duck-typing
                                        open classes
                         (almost) everything is executable ruby code




Saturday, May 30, 2009
Should You Learn Ruby?




Saturday, May 30, 2009
Corey Haines
                             Journeyman
                              Developer

                          That’s Me!




                            www.coreyhaines.com

                           coreyhaines@gmail.com

Saturday, May 30, 2009
On To Ruby




Saturday, May 30, 2009
“...trying to make Ruby
                         natural, not simple.”
                                - Yukihiro Matsumoto
                                                        “Matz”




                                    image courtesy Jim Lindley on flickr




Saturday, May 30, 2009
Qualities


                          Simple Syntax
                         Object-Oriented
                           Duck-Typing
                             Blocks
                          Open Classes


Saturday, May 30, 2009
Qualities


                          Simple Syntax
                         Object-Oriented
                           Duck-Typing
                             Blocks
                          Open Classes


Saturday, May 30, 2009
Initializers



                 arr = [1, 6, 2, 3, 5]

                 arr2 = [“Element”, “Another one”]

                 lookup = { :ruby => “love”,
                            :c_sharp => “good too”,
                            :python => “cool” }




Saturday, May 30, 2009
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
>> r = Rectangle.new(5, 20)
               => #<Rectangle:0x3691d8 @width=5, @height=20>
               >> r.area
               => 100




Saturday, May 30, 2009
Qualities


                          Simple Syntax
                         Object-Oriented
                           Duck-Typing
                             Blocks
                          Open Classes


Saturday, May 30, 2009
Everything is an object


                         >> 9.succ
                         => 10
                         >> 9.nil?
                         => false
                         >> 9.between? 8, 10
                         => true
                         >> 9.class
                         => Fixnum




Saturday, May 30, 2009
No Really

                         >> 9.succ
                         => 10
                         >> 9.nil?
                         => false
                         >> 9.between? 8, 10
                         => true                    Wha?
                         >> 9.class
                         => Fixnum
                         >> Fixnum.class
                         => Class




Saturday, May 30, 2009
Ever written something like this?


             public void MakeItQuack<T>(T quacker)
             where T : ICanQuack
             {
               quacker.Quack();
             }




Saturday, May 30, 2009
Really Wanted



           public void MakeItQuack<T>(T quacker)
           where T can quack
           {
             quacker.quack();
           }




Saturday, May 30, 2009
Qualities


                          Simple Syntax
                         Object-Oriented
                           Duck-Typing
                             Blocks
                          Open Classes


Saturday, May 30, 2009
No, not that kind




Saturday, May 30, 2009
Duck-Typing




                                   Walks like a duck
                                   Quacks like a duck
                                   Must be a duck?




Saturday, May 30, 2009
Well, no



                         But, we can interact with it like a duck!


                         And Pretend!




Saturday, May 30, 2009
def make_it_quack(quacker)
                          quacker.quack();
                         end




Saturday, May 30, 2009
Type != Class




                         Behavior/Interaction-Orientation




Saturday, May 30, 2009
Qualities


                          Simple Syntax
                         Object-Oriented
                           Duck-Typing
                             Blocks
                          Open Classes


Saturday, May 30, 2009
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
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
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
Qualities


                          Simple Syntax
                         Object-Oriented
                           Duck-Typing
                             Blocks
                          Open Classes


Saturday, May 30, 2009
Open Classes




                         Say goodbye to sealed/virtual/override/argh




Saturday, May 30, 2009
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
As You Wish




                         class NilClass
                            def empty?
                              true
                            end
                         end




Saturday, May 30, 2009
def convert(to_convert)
                           return to_convert if to_convert.empty?
                           do_conversion(to_convert)
                         end




Saturday, May 30, 2009
Setting Time




                         current_time = 17




Saturday, May 30, 2009
write the code you wish you had


                                 current_time = 5.pm




Saturday, May 30, 2009
Then get it working



                            class Fixnum
                             def pm
                              self + 12
                             end
                            end




Saturday, May 30, 2009
Type != Class (redux)




                         a = “coreyhaines@gmail.com;me@coreyhaines.com”




Saturday, May 30, 2009
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
Remember

                         With great power comes great responsibility




Saturday, May 30, 2009
Qualities


                          Simple Syntax
                         Object-Oriented
                           Duck-Typing
                             Blocks
                          Open Classes


Saturday, May 30, 2009
Qualities

                         Awesomeness!
                             Simple Syntax
                            Object-Oriented
                              Duck-Typing
                                Blocks
                             Open Classes


Saturday, May 30, 2009
Method Missing




Saturday, May 30, 2009
Examples




                         Builder




Saturday, May 30, 2009
Mixins




Saturday, May 30, 2009
Type != Class




Saturday, May 30, 2009
Examples




                         Email Addresses




Saturday, May 30, 2009
defining methods




Saturday, May 30, 2009
Examples




                         Email Addresses




Saturday, May 30, 2009

More Related Content

Recently uploaded

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 

Recently uploaded (20)

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 

Featured

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 

Featured (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Intro To Ruby

  • 1. Corey Haines, Journeyman Developer Ruby It really is Love 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
  • 43. Examples Builder Saturday, May 30, 2009
  • 45. Type != Class Saturday, May 30, 2009
  • 46. Examples Email Addresses Saturday, May 30, 2009
  • 48. Examples Email Addresses Saturday, May 30, 2009