SlideShare a Scribd company logo
Ruby
BinhBV
2014/03
Ruby.history()
• Developed in Japan by Yukihiro "Matz" Matsumoto (only Japanese domestic )
• First public release in 1995(ver 0.95).
• Ruby 1.6: September 2000
• By 2000, Ruby was more popular than Python in Japan
• In September 2000, the first English language book Programming Ruby was
printed
• Ruby 1.8: released in August 2003
• July 2004, Hansson first released Ruby on Rails as open source
• Ruby 1.9: December 2007
• Ruby 1.9 introduces many changes over the 1.8 series
• Ruby 2.1 (was released on Christmas Day in 2013)
2
Actually, I didn't make the claim that
Ruby follows the principle of least
surprise. Someone felt the design of
Ruby follows that philosophy, so they
started saying that. I didn't bring that up,
actually.
Ruby.is_a?
• OOP language
• Interpreted scripting language
• Duck Typing style
• Inspired Perl, Python, SmallTalk
• Syntax is generally like all other programming languages
3
OOP Language
• Everything, including a literal, is an object
-199.abs # => 199
"ice is nice".length # => 11
"ruby is cool.".index("u") # => 1
• The constructor is always named “initialize” instead of the name of the class.
Interpreted scripting language
• No compilation required
Duck typing and syntactic sugars
• no need for type definition
• There’s no casting. Just call the methods
• no semicolons at the end of the line
• no parentheses for method invocations
• operators overload (operator_overload.rb)
• getters/setters automatically
• All member variables are private, Ruby have 3 methods: attr_accessor, attr_reader and
attr_writer
Inspired Perl, Python, SmallTalk
• Actual, I not yet do with Perl, so I am not sure about perl. In this chapter, I will compare with python
• There’s an interactive prompt (called irb).
• Indentation syntax (uses whitespace to delimit program blocks)
• Objects are strongly and dynamically typed.
• Everything is an object, and variables are just references to objects.
Syntax
Generally its like all other programming languages,
Except with a few syntax changes
Conditions
• General
if (condition){
# do xxx
} else if (condition){
# do yyy
} else {
# do zzz
}
• Ruby
if condition
# …
elseif condition
# …
else
#…
end
b = a if condition
unless condition
# ..
else
# ..
end
Loops
• General
while (condition){
#…
}
for(int i, i < array.length, i++){
#…
}
for each (String s : lst){
}
• Ruby
while i < 10
# …
end
until i == 10
# ….
end
people.each {|person| ….}
people.each do |person|
puts person.name
end
Exception Handling
• General
try {
#
} catch (Exception e){
#
} finally {
#
}
• Ruby
begin
#
rescue RuntimeException => e
#
rescue e
#
ensure
# …
end
Meta programming
Magic
Why ruby?
Why not ruby?
Ad

More Related Content

What's hot (6)

Intro for RoR
Intro for RoRIntro for RoR
Intro for RoR
Vigneshwaran Seetharaman
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
Mark Menard
 
Why i love ruby than x
Why i love ruby than xWhy i love ruby than x
Why i love ruby than x
Samnang Chhun
 
Power Leveling your TypeScript
Power Leveling your TypeScriptPower Leveling your TypeScript
Power Leveling your TypeScript
Offirmo
 
Introduction To Rust Language - Chester Devs
Introduction To Rust Language - Chester DevsIntroduction To Rust Language - Chester Devs
Introduction To Rust Language - Chester Devs
Andy Lowry
 
CSP: Huh? And Components
CSP: Huh? And ComponentsCSP: Huh? And Components
CSP: Huh? And Components
Daniel Fagnan
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
Mark Menard
 
Why i love ruby than x
Why i love ruby than xWhy i love ruby than x
Why i love ruby than x
Samnang Chhun
 
Power Leveling your TypeScript
Power Leveling your TypeScriptPower Leveling your TypeScript
Power Leveling your TypeScript
Offirmo
 
Introduction To Rust Language - Chester Devs
Introduction To Rust Language - Chester DevsIntroduction To Rust Language - Chester Devs
Introduction To Rust Language - Chester Devs
Andy Lowry
 
CSP: Huh? And Components
CSP: Huh? And ComponentsCSP: Huh? And Components
CSP: Huh? And Components
Daniel Fagnan
 

Similar to Ruby introductions (20)

Ruby an overall approach
Ruby an overall approachRuby an overall approach
Ruby an overall approach
Felipe Schmitt
 
JRuby: The Hard Parts
JRuby: The Hard PartsJRuby: The Hard Parts
JRuby: The Hard Parts
Charles Nutter
 
Intro To Ror
Intro To RorIntro To Ror
Intro To Ror
myuser
 
How to use Ruby in QA, DevOps, Development. Ruby lang Intro
How to use Ruby in QA, DevOps, Development. Ruby lang IntroHow to use Ruby in QA, DevOps, Development. Ruby lang Intro
How to use Ruby in QA, DevOps, Development. Ruby lang Intro
Viacheslav Horbovskykh
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1
Henry S
 
Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)
Muhammad Haseeb Shahid
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
knoppix
 
ruby_vs_perl_and_python
ruby_vs_perl_and_pythonruby_vs_perl_and_python
ruby_vs_perl_and_python
tutorialsruby
 
ruby_vs_perl_and_python
ruby_vs_perl_and_pythonruby_vs_perl_and_python
ruby_vs_perl_and_python
tutorialsruby
 
What can Ruby learn from Python (and vice versa)?
What can Ruby learn from Python (and vice versa)?What can Ruby learn from Python (and vice versa)?
What can Ruby learn from Python (and vice versa)?
Reuven Lerner
 
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
mametter
 
Ruby Presentation
Ruby Presentation Ruby Presentation
Ruby Presentation
platico_dev
 
Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talk
Reuven Lerner
 
Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010
ssoroka
 
Ruby in prijatelji
Ruby in prijateljiRuby in prijatelji
Ruby in prijatelji
Oto Brglez
 
TypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without AnnotationsTypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without Annotations
mametter
 
Ievgenii Narovlianskyi - Ruby is not just a gem
Ievgenii Narovlianskyi - Ruby is not just a gemIevgenii Narovlianskyi - Ruby is not just a gem
Ievgenii Narovlianskyi - Ruby is not just a gem
SeniorDevOnly
 
Initiation à Ruby on Rails
Initiation à Ruby on RailsInitiation à Ruby on Rails
Initiation à Ruby on Rails
Microsoft Technet France
 
Adventures of java developer in ruby world
Adventures of java developer in ruby worldAdventures of java developer in ruby world
Adventures of java developer in ruby world
Orest Ivasiv
 
10 Things you should know about Ruby
10 Things you should know about Ruby10 Things you should know about Ruby
10 Things you should know about Ruby
sikachu
 
Ruby an overall approach
Ruby an overall approachRuby an overall approach
Ruby an overall approach
Felipe Schmitt
 
Intro To Ror
Intro To RorIntro To Ror
Intro To Ror
myuser
 
How to use Ruby in QA, DevOps, Development. Ruby lang Intro
How to use Ruby in QA, DevOps, Development. Ruby lang IntroHow to use Ruby in QA, DevOps, Development. Ruby lang Intro
How to use Ruby in QA, DevOps, Development. Ruby lang Intro
Viacheslav Horbovskykh
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1
Henry S
 
Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)
Muhammad Haseeb Shahid
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
knoppix
 
ruby_vs_perl_and_python
ruby_vs_perl_and_pythonruby_vs_perl_and_python
ruby_vs_perl_and_python
tutorialsruby
 
ruby_vs_perl_and_python
ruby_vs_perl_and_pythonruby_vs_perl_and_python
ruby_vs_perl_and_python
tutorialsruby
 
What can Ruby learn from Python (and vice versa)?
What can Ruby learn from Python (and vice versa)?What can Ruby learn from Python (and vice versa)?
What can Ruby learn from Python (and vice versa)?
Reuven Lerner
 
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
mametter
 
Ruby Presentation
Ruby Presentation Ruby Presentation
Ruby Presentation
platico_dev
 
Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talk
Reuven Lerner
 
Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010
ssoroka
 
Ruby in prijatelji
Ruby in prijateljiRuby in prijatelji
Ruby in prijatelji
Oto Brglez
 
TypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without AnnotationsTypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without Annotations
mametter
 
Ievgenii Narovlianskyi - Ruby is not just a gem
Ievgenii Narovlianskyi - Ruby is not just a gemIevgenii Narovlianskyi - Ruby is not just a gem
Ievgenii Narovlianskyi - Ruby is not just a gem
SeniorDevOnly
 
Adventures of java developer in ruby world
Adventures of java developer in ruby worldAdventures of java developer in ruby world
Adventures of java developer in ruby world
Orest Ivasiv
 
10 Things you should know about Ruby
10 Things you should know about Ruby10 Things you should know about Ruby
10 Things you should know about Ruby
sikachu
 
Ad

Recently uploaded (20)

Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Ad

Ruby introductions

  • 2. Ruby.history() • Developed in Japan by Yukihiro "Matz" Matsumoto (only Japanese domestic ) • First public release in 1995(ver 0.95). • Ruby 1.6: September 2000 • By 2000, Ruby was more popular than Python in Japan • In September 2000, the first English language book Programming Ruby was printed • Ruby 1.8: released in August 2003 • July 2004, Hansson first released Ruby on Rails as open source • Ruby 1.9: December 2007 • Ruby 1.9 introduces many changes over the 1.8 series • Ruby 2.1 (was released on Christmas Day in 2013) 2 Actually, I didn't make the claim that Ruby follows the principle of least surprise. Someone felt the design of Ruby follows that philosophy, so they started saying that. I didn't bring that up, actually.
  • 3. Ruby.is_a? • OOP language • Interpreted scripting language • Duck Typing style • Inspired Perl, Python, SmallTalk • Syntax is generally like all other programming languages 3
  • 4. OOP Language • Everything, including a literal, is an object -199.abs # => 199 "ice is nice".length # => 11 "ruby is cool.".index("u") # => 1 • The constructor is always named “initialize” instead of the name of the class.
  • 5. Interpreted scripting language • No compilation required
  • 6. Duck typing and syntactic sugars • no need for type definition • There’s no casting. Just call the methods • no semicolons at the end of the line • no parentheses for method invocations • operators overload (operator_overload.rb) • getters/setters automatically • All member variables are private, Ruby have 3 methods: attr_accessor, attr_reader and attr_writer
  • 7. Inspired Perl, Python, SmallTalk • Actual, I not yet do with Perl, so I am not sure about perl. In this chapter, I will compare with python • There’s an interactive prompt (called irb). • Indentation syntax (uses whitespace to delimit program blocks) • Objects are strongly and dynamically typed. • Everything is an object, and variables are just references to objects.
  • 8. Syntax Generally its like all other programming languages, Except with a few syntax changes
  • 9. Conditions • General if (condition){ # do xxx } else if (condition){ # do yyy } else { # do zzz } • Ruby if condition # … elseif condition # … else #… end b = a if condition unless condition # .. else # .. end
  • 10. Loops • General while (condition){ #… } for(int i, i < array.length, i++){ #… } for each (String s : lst){ } • Ruby while i < 10 # … end until i == 10 # …. end people.each {|person| ….} people.each do |person| puts person.name end
  • 11. Exception Handling • General try { # } catch (Exception e){ # } finally { # } • Ruby begin # rescue RuntimeException => e # rescue e # ensure # … end
  • 13. Magic