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

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Recently uploaded (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

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