SlideShare a Scribd company logo
1 of 11
Let's Learn Ruby AQAP
As Quickly As Possible!
 Run the interactive ruby shell – irb
 Suggest using Netbeans – download ALL
2
2 + 6
22 / 4  5
Float(22)/4
22.0 / 4
3 * 3
3 ** 3
big_number = 1_000_000_000 (underscores not required
and can go anywhere allowed to make it more readable –
commas hard to see)
Simple Ruby Number Objects
3
Math.sqrt( 9 )
Math.methods
9.methods  will tell you what methods can be used with 9
27.class  will tell you what class 27 belongs to (Fixnum)
3.times { print "Ho! " }
1.upto( 5 ) { |i| puts i }  defines i as the iterator variable
termed a “code block”
Anonymous delegate given the name i
Ruby Number Methods
4
one = "1"
two = "2"
one + two  string concat, right?
Integer( one ) + Integer( two )  casts and then adds
12.to_s  calls to string method, but wants you to request
conversion
print "Happy ", 12.to_s, "th Birthday!"
puts "Happy ", 12.to_s, "th Birthday!"
puts "Happy " + 12 + "th Birthday!"
Number Conversions
5
a1 = "this is a stringn”  evaluate backslash and contents of
#{} inside of the string. Termed string interpolation
a2 = 'and so is thisn‘  will see the n as no evaluation is
done
print a1
print a2
answer = “joy”
puts "The meaning of life is #{answer}"
puts "There's #{24*60*60} seconds in a day"
Ruby String Objects
6
formatted_text = <<END_OF_TEXT
Let us turn our thoughts today
To Martin Luther King
And recognize that there are ties between us
All men and women
Living on the Earth
Ties of hope and love
Sister and brotherhood
That we are bound together
In our desire to see the world become
A place in which our children
Can grow free and strong
END_OF_TEXT  any delimiter – as long as it matches
print formatted_text  interpretation does work
Ruby Here Documents
7
String.methods.sort  sorted list of String methods
formatted_text.size  number of characters
formatted_text.downcase  lowercase
formatted_text.upcase  uppercase
formatted_text.capitalize!  ! means to actually change the
object in place (rather than return a changed copy)
formatted_text.reverse  reverses all characters
formatted_text.empty?  boolean indicated by ?
only used in method names (not variables)
Ruby String Methods
8
song_lines = formatted_text.to_a  to array
(1..10).to_a  [1,2,3,4,5,6,7,8,9,10] from a range
(denoted ..)
(‘a’..’e’).to_a  [“a”, “b”, “c”, “d”, “e”]
print song_lines[1]
print song_lines[5]
print song_lines[99]  Gives nil if used when out of range,
will add to array if assign outside of range.
print song_lines
print formatted_text
song_lines.class  Array
formatted_text.class  String
Working with Ruby Strings
9
Same variable can hold any type at different times…
a = 42
puts a
a = "The Ruby Programming Language"
puts a
a = 1.8
puts a
What About Variable Type?
10
 Everything - numbers, strings, data structures,
Class itself etc. - is an object
 Methods are invoked using the dot (".") notation
 Variables are dynamically created as needed
(problems with typos), but will tell you during
execution if you access something without a
value.
 The traditional notion of a variable's "type" is
not something the Ruby programmer concerns
themselves with (too much)
11

More Related Content

Viewers also liked

Atul Westernhills Phase II Brochure - Zricks.com
Atul Westernhills Phase II Brochure - Zricks.comAtul Westernhills Phase II Brochure - Zricks.com
Atul Westernhills Phase II Brochure - Zricks.comZricks.com
 
Casa Grande Padi Brochure - Zricks.com
Casa Grande Padi Brochure - Zricks.comCasa Grande Padi Brochure - Zricks.com
Casa Grande Padi Brochure - Zricks.comZricks.com
 
Shriram Southern Crest Brochure - Zricks.com
Shriram Southern Crest Brochure - Zricks.comShriram Southern Crest Brochure - Zricks.com
Shriram Southern Crest Brochure - Zricks.comZricks.com
 
Oberoi Commerz Brochure - Zricks.com
Oberoi Commerz Brochure - Zricks.comOberoi Commerz Brochure - Zricks.com
Oberoi Commerz Brochure - Zricks.comZricks.com
 
Paranjape Xion Brochure - Zricks.com
Paranjape Xion Brochure - Zricks.comParanjape Xion Brochure - Zricks.com
Paranjape Xion Brochure - Zricks.comZricks.com
 
Panvelkar Green City Brochure - Zricks.com
Panvelkar Green City Brochure - Zricks.comPanvelkar Green City Brochure - Zricks.com
Panvelkar Green City Brochure - Zricks.comZricks.com
 
Sterling Villa Grande Brochure - Zricks.com
Sterling Villa Grande Brochure - Zricks.comSterling Villa Grande Brochure - Zricks.com
Sterling Villa Grande Brochure - Zricks.comZricks.com
 
Assetz 27 Park Avenue Brochure - Zricks.com
Assetz 27 Park Avenue Brochure - Zricks.comAssetz 27 Park Avenue Brochure - Zricks.com
Assetz 27 Park Avenue Brochure - Zricks.comZricks.com
 
Mantra Divine Brochure - Zricks.com
Mantra Divine Brochure - Zricks.comMantra Divine Brochure - Zricks.com
Mantra Divine Brochure - Zricks.comZricks.com
 
Majestique Manhattan Brochure - Zricks.com
Majestique Manhattan Brochure - Zricks.comMajestique Manhattan Brochure - Zricks.com
Majestique Manhattan Brochure - Zricks.comZricks.com
 
Ekta Legranz Brochure - Zricks.com
Ekta Legranz Brochure - Zricks.comEkta Legranz Brochure - Zricks.com
Ekta Legranz Brochure - Zricks.comZricks.com
 
Arge Urban Bloom Brochure - Zricks.com
Arge Urban Bloom Brochure - Zricks.comArge Urban Bloom Brochure - Zricks.com
Arge Urban Bloom Brochure - Zricks.comZricks.com
 
Prestige Silver Crest Brochure - Zricks.com
Prestige Silver Crest Brochure - Zricks.comPrestige Silver Crest Brochure - Zricks.com
Prestige Silver Crest Brochure - Zricks.comZricks.com
 
Arge Helios Brochure - Zricks.com
Arge Helios Brochure - Zricks.comArge Helios Brochure - Zricks.com
Arge Helios Brochure - Zricks.comZricks.com
 

Viewers also liked (14)

Atul Westernhills Phase II Brochure - Zricks.com
Atul Westernhills Phase II Brochure - Zricks.comAtul Westernhills Phase II Brochure - Zricks.com
Atul Westernhills Phase II Brochure - Zricks.com
 
Casa Grande Padi Brochure - Zricks.com
Casa Grande Padi Brochure - Zricks.comCasa Grande Padi Brochure - Zricks.com
Casa Grande Padi Brochure - Zricks.com
 
Shriram Southern Crest Brochure - Zricks.com
Shriram Southern Crest Brochure - Zricks.comShriram Southern Crest Brochure - Zricks.com
Shriram Southern Crest Brochure - Zricks.com
 
Oberoi Commerz Brochure - Zricks.com
Oberoi Commerz Brochure - Zricks.comOberoi Commerz Brochure - Zricks.com
Oberoi Commerz Brochure - Zricks.com
 
Paranjape Xion Brochure - Zricks.com
Paranjape Xion Brochure - Zricks.comParanjape Xion Brochure - Zricks.com
Paranjape Xion Brochure - Zricks.com
 
Panvelkar Green City Brochure - Zricks.com
Panvelkar Green City Brochure - Zricks.comPanvelkar Green City Brochure - Zricks.com
Panvelkar Green City Brochure - Zricks.com
 
Sterling Villa Grande Brochure - Zricks.com
Sterling Villa Grande Brochure - Zricks.comSterling Villa Grande Brochure - Zricks.com
Sterling Villa Grande Brochure - Zricks.com
 
Assetz 27 Park Avenue Brochure - Zricks.com
Assetz 27 Park Avenue Brochure - Zricks.comAssetz 27 Park Avenue Brochure - Zricks.com
Assetz 27 Park Avenue Brochure - Zricks.com
 
Mantra Divine Brochure - Zricks.com
Mantra Divine Brochure - Zricks.comMantra Divine Brochure - Zricks.com
Mantra Divine Brochure - Zricks.com
 
Majestique Manhattan Brochure - Zricks.com
Majestique Manhattan Brochure - Zricks.comMajestique Manhattan Brochure - Zricks.com
Majestique Manhattan Brochure - Zricks.com
 
Ekta Legranz Brochure - Zricks.com
Ekta Legranz Brochure - Zricks.comEkta Legranz Brochure - Zricks.com
Ekta Legranz Brochure - Zricks.com
 
Arge Urban Bloom Brochure - Zricks.com
Arge Urban Bloom Brochure - Zricks.comArge Urban Bloom Brochure - Zricks.com
Arge Urban Bloom Brochure - Zricks.com
 
Prestige Silver Crest Brochure - Zricks.com
Prestige Silver Crest Brochure - Zricks.comPrestige Silver Crest Brochure - Zricks.com
Prestige Silver Crest Brochure - Zricks.com
 
Arge Helios Brochure - Zricks.com
Arge Helios Brochure - Zricks.comArge Helios Brochure - Zricks.com
Arge Helios Brochure - Zricks.com
 

Similar to Learn ruby intro

Ruby -the wheel Technology
Ruby -the wheel TechnologyRuby -the wheel Technology
Ruby -the wheel Technologyppparthpatel123
 
Ruby from zero to hero
Ruby from zero to heroRuby from zero to hero
Ruby from zero to heroDiego Lemos
 
Ruby data types and objects
Ruby   data types and objectsRuby   data types and objects
Ruby data types and objectsHarkamal Singh
 
Scala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameScala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameAntony Stubbs
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9sagaroceanic11
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9sagaroceanic11
 
Ruby — An introduction
Ruby — An introductionRuby — An introduction
Ruby — An introductionGonçalo Silva
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Examshishamrizvi
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Mark Menard
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsRaghu nath
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in PythonSujith Kumar
 
Intro to Ruby/Rails at TechLady Hackathon
Intro to Ruby/Rails at TechLady HackathonIntro to Ruby/Rails at TechLady Hackathon
Intro to Ruby/Rails at TechLady Hackathonkdmcclin
 

Similar to Learn ruby intro (20)

Ruby -the wheel Technology
Ruby -the wheel TechnologyRuby -the wheel Technology
Ruby -the wheel Technology
 
Ruby from zero to hero
Ruby from zero to heroRuby from zero to hero
Ruby from zero to hero
 
Ruby data types and objects
Ruby   data types and objectsRuby   data types and objects
Ruby data types and objects
 
Ruby_Basic
Ruby_BasicRuby_Basic
Ruby_Basic
 
Scala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameScala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love Game
 
Ruby
RubyRuby
Ruby
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9
 
Ruby Basics
Ruby BasicsRuby Basics
Ruby Basics
 
Ruby basics
Ruby basicsRuby basics
Ruby basics
 
Ruby — An introduction
Ruby — An introductionRuby — An introduction
Ruby — An introduction
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
 
Regex lecture
Regex lectureRegex lecture
Regex lecture
 
Ruby Programming
Ruby ProgrammingRuby Programming
Ruby Programming
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
Ruby
RubyRuby
Ruby
 
Intro to Ruby/Rails at TechLady Hackathon
Intro to Ruby/Rails at TechLady HackathonIntro to Ruby/Rails at TechLady Hackathon
Intro to Ruby/Rails at TechLady Hackathon
 

More from Young Alista

Google appenginejava.ppt
Google appenginejava.pptGoogle appenginejava.ppt
Google appenginejava.pptYoung Alista
 
Motivation for multithreaded architectures
Motivation for multithreaded architecturesMotivation for multithreaded architectures
Motivation for multithreaded architecturesYoung Alista
 
Serialization/deserialization
Serialization/deserializationSerialization/deserialization
Serialization/deserializationYoung Alista
 
Big picture of data mining
Big picture of data miningBig picture of data mining
Big picture of data miningYoung Alista
 
Business analytics and data mining
Business analytics and data miningBusiness analytics and data mining
Business analytics and data miningYoung Alista
 
Data mining and knowledge discovery
Data mining and knowledge discoveryData mining and knowledge discovery
Data mining and knowledge discoveryYoung Alista
 
Directory based cache coherence
Directory based cache coherenceDirectory based cache coherence
Directory based cache coherenceYoung Alista
 
Hardware managed cache
Hardware managed cacheHardware managed cache
Hardware managed cacheYoung Alista
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksYoung Alista
 
Optimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessorsOptimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessorsYoung Alista
 
Abstract data types
Abstract data typesAbstract data types
Abstract data typesYoung Alista
 
Concurrency with java
Concurrency with javaConcurrency with java
Concurrency with javaYoung Alista
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsYoung Alista
 
Cobol, lisp, and python
Cobol, lisp, and pythonCobol, lisp, and python
Cobol, lisp, and pythonYoung Alista
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisYoung Alista
 

More from Young Alista (20)

Google appenginejava.ppt
Google appenginejava.pptGoogle appenginejava.ppt
Google appenginejava.ppt
 
Motivation for multithreaded architectures
Motivation for multithreaded architecturesMotivation for multithreaded architectures
Motivation for multithreaded architectures
 
Serialization/deserialization
Serialization/deserializationSerialization/deserialization
Serialization/deserialization
 
Big picture of data mining
Big picture of data miningBig picture of data mining
Big picture of data mining
 
Business analytics and data mining
Business analytics and data miningBusiness analytics and data mining
Business analytics and data mining
 
Data mining and knowledge discovery
Data mining and knowledge discoveryData mining and knowledge discovery
Data mining and knowledge discovery
 
Directory based cache coherence
Directory based cache coherenceDirectory based cache coherence
Directory based cache coherence
 
Cache recap
Cache recapCache recap
Cache recap
 
Hardware managed cache
Hardware managed cacheHardware managed cache
Hardware managed cache
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
Object model
Object modelObject model
Object model
 
Optimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessorsOptimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessors
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Abstraction file
Abstraction fileAbstraction file
Abstraction file
 
Concurrency with java
Concurrency with javaConcurrency with java
Concurrency with java
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Abstract class
Abstract classAbstract class
Abstract class
 
Inheritance
InheritanceInheritance
Inheritance
 
Cobol, lisp, and python
Cobol, lisp, and pythonCobol, lisp, and python
Cobol, lisp, and python
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 

Recently uploaded

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
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
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
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
 

Learn ruby intro

  • 1. Let's Learn Ruby AQAP As Quickly As Possible!
  • 2.  Run the interactive ruby shell – irb  Suggest using Netbeans – download ALL 2
  • 3. 2 + 6 22 / 4  5 Float(22)/4 22.0 / 4 3 * 3 3 ** 3 big_number = 1_000_000_000 (underscores not required and can go anywhere allowed to make it more readable – commas hard to see) Simple Ruby Number Objects 3
  • 4. Math.sqrt( 9 ) Math.methods 9.methods  will tell you what methods can be used with 9 27.class  will tell you what class 27 belongs to (Fixnum) 3.times { print "Ho! " } 1.upto( 5 ) { |i| puts i }  defines i as the iterator variable termed a “code block” Anonymous delegate given the name i Ruby Number Methods 4
  • 5. one = "1" two = "2" one + two  string concat, right? Integer( one ) + Integer( two )  casts and then adds 12.to_s  calls to string method, but wants you to request conversion print "Happy ", 12.to_s, "th Birthday!" puts "Happy ", 12.to_s, "th Birthday!" puts "Happy " + 12 + "th Birthday!" Number Conversions 5
  • 6. a1 = "this is a stringn”  evaluate backslash and contents of #{} inside of the string. Termed string interpolation a2 = 'and so is thisn‘  will see the n as no evaluation is done print a1 print a2 answer = “joy” puts "The meaning of life is #{answer}" puts "There's #{24*60*60} seconds in a day" Ruby String Objects 6
  • 7. formatted_text = <<END_OF_TEXT Let us turn our thoughts today To Martin Luther King And recognize that there are ties between us All men and women Living on the Earth Ties of hope and love Sister and brotherhood That we are bound together In our desire to see the world become A place in which our children Can grow free and strong END_OF_TEXT  any delimiter – as long as it matches print formatted_text  interpretation does work Ruby Here Documents 7
  • 8. String.methods.sort  sorted list of String methods formatted_text.size  number of characters formatted_text.downcase  lowercase formatted_text.upcase  uppercase formatted_text.capitalize!  ! means to actually change the object in place (rather than return a changed copy) formatted_text.reverse  reverses all characters formatted_text.empty?  boolean indicated by ? only used in method names (not variables) Ruby String Methods 8
  • 9. song_lines = formatted_text.to_a  to array (1..10).to_a  [1,2,3,4,5,6,7,8,9,10] from a range (denoted ..) (‘a’..’e’).to_a  [“a”, “b”, “c”, “d”, “e”] print song_lines[1] print song_lines[5] print song_lines[99]  Gives nil if used when out of range, will add to array if assign outside of range. print song_lines print formatted_text song_lines.class  Array formatted_text.class  String Working with Ruby Strings 9
  • 10. Same variable can hold any type at different times… a = 42 puts a a = "The Ruby Programming Language" puts a a = 1.8 puts a What About Variable Type? 10
  • 11.  Everything - numbers, strings, data structures, Class itself etc. - is an object  Methods are invoked using the dot (".") notation  Variables are dynamically created as needed (problems with typos), but will tell you during execution if you access something without a value.  The traditional notion of a variable's "type" is not something the Ruby programmer concerns themselves with (too much) 11

Editor's Notes

  1. What do you notice that seems more “object oriented” than other languages?