SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Dernier

Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
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
 
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
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
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
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 

Dernier (20)

Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
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
 
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
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
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
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 

En vedette

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
 

En vedette (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