SlideShare a Scribd company logo
1 of 12
Download to read offline
Ruby Data Types
Dalal Alrayes

@dalrayes
Hi, I m Dalal
Everything is an Object
• An integer is an object 12
• A float is an object 1.333
• A string is an object “Ruby is awesome”
• An array is an object [“apple”,“orange”]
• A hash is an object { state: “Illinois”,

zipcode: “60606”}
• & many, other types (blocks, lambdas, modules,
classes) are also objects

Strings
• Anything surrounded by
• Text based characters, typically representing words
“Ruby is fun”
“I am a string”
“S”
• But can also be non-alphabet characters
“78”
“W2 2Sy”
quotes
String methods
• Start up your terminal
• Type ‘irb’
• Let’s look up the docs
Arrays
bulls = [“Rose”, “Butler”, “Gasol”, “Noah”, “Brooks”]
0 1 2 3 4
• Each element in the array is associated with and referred
to by an index
bulls[0] = ?
bulls[4] = ?
• Ordered, integer-indexed collection
• Can hold objects such as strings, integers, hashes and
other array objects
Indexing
array = [ “good”, “times”, 2015, “09”, “yup” ]
array[0] [1] [2] [3] [4]
array[-1][-2][-3][-4][-5]
Array methods
• Start up your terminal
• Type ‘irb’
• Let’s look up the docs (google: ruby docs array)
Hashes
• Dictionary like collection of unique key-value pairs
groceries = {
“apples” => 3,
“kale” => 1,
“chips” => 7
}
• Retrieve or create an entry by using its key
groceries[“apples”]

groceries[“ice cream”] = 2
Hashes, ctd
• Implicit Form

groceries = {“apples” => 3, “kale” => 1}
• Symbols
groceries = {apples: 3, kale: 1}
style = {color: “red”, size: 3}
Hash methods
• Start up your terminal
• Type ‘irb’
• Let’s look up the docs (try google: ruby 2.2 docs
hash)
• Everything is an object
• Strings are anything in between quotes
• Arrays are indexed and start at 0
• Hashes are unique key-value pairs
• Check the official ruby docs for methods for
each!
Recap

More Related Content

Viewers also liked

Cмольська л.м. путівник самоменеджера
Cмольська л.м. путівник самоменеджераCмольська л.м. путівник самоменеджера
Cмольська л.м. путівник самоменеджераnatalia0803
 
5Echo - Who we are
5Echo - Who we are 5Echo - Who we are
5Echo - Who we are Team 5Echo
 
Rotech Intro 4-8.1
Rotech Intro 4-8.1Rotech Intro 4-8.1
Rotech Intro 4-8.1Reuven Koter
 
Media Studies Evaluation
Media Studies EvaluationMedia Studies Evaluation
Media Studies Evaluationtadimutenga
 
Lila Downs y la Banda Tierra Mojada
Lila Downs y la Banda Tierra MojadaLila Downs y la Banda Tierra Mojada
Lila Downs y la Banda Tierra MojadaViveOaxacamx
 
CFA Examination Results Level 1
CFA Examination Results Level 1CFA Examination Results Level 1
CFA Examination Results Level 1Nugroho Nitiyoso
 
CSCM Chapter 1 construction supply chain management part 2
CSCM Chapter 1 construction supply chain management part 2CSCM Chapter 1 construction supply chain management part 2
CSCM Chapter 1 construction supply chain management part 2Est
 
PISA 2015 A Sneak Preview
PISA 2015   A Sneak PreviewPISA 2015   A Sneak Preview
PISA 2015 A Sneak PreviewEduSkills OECD
 
2016 Salesforce Release Highlights
2016 Salesforce Release Highlights2016 Salesforce Release Highlights
2016 Salesforce Release HighlightsThinqloud
 

Viewers also liked (12)

Cмольська л.м. путівник самоменеджера
Cмольська л.м. путівник самоменеджераCмольська л.м. путівник самоменеджера
Cмольська л.м. путівник самоменеджера
 
5Echo - Who we are
5Echo - Who we are 5Echo - Who we are
5Echo - Who we are
 
Rotech Intro 4-8.1
Rotech Intro 4-8.1Rotech Intro 4-8.1
Rotech Intro 4-8.1
 
Media Studies Evaluation
Media Studies EvaluationMedia Studies Evaluation
Media Studies Evaluation
 
Lila Downs y la Banda Tierra Mojada
Lila Downs y la Banda Tierra MojadaLila Downs y la Banda Tierra Mojada
Lila Downs y la Banda Tierra Mojada
 
Dubai Presentation
Dubai PresentationDubai Presentation
Dubai Presentation
 
CFA Examination Results Level 1
CFA Examination Results Level 1CFA Examination Results Level 1
CFA Examination Results Level 1
 
CSCM Chapter 1 construction supply chain management part 2
CSCM Chapter 1 construction supply chain management part 2CSCM Chapter 1 construction supply chain management part 2
CSCM Chapter 1 construction supply chain management part 2
 
Ingenio eng presentation
Ingenio eng presentationIngenio eng presentation
Ingenio eng presentation
 
PISA 2015 A Sneak Preview
PISA 2015   A Sneak PreviewPISA 2015   A Sneak Preview
PISA 2015 A Sneak Preview
 
F elektrochemie
F elektrochemieF elektrochemie
F elektrochemie
 
2016 Salesforce Release Highlights
2016 Salesforce Release Highlights2016 Salesforce Release Highlights
2016 Salesforce Release Highlights
 

Recently uploaded

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 

Recently uploaded (20)

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 

Ruby data types

  • 1. Ruby Data Types Dalal Alrayes
 @dalrayes
  • 2. Hi, I m Dalal
  • 3. Everything is an Object • An integer is an object 12 • A float is an object 1.333 • A string is an object “Ruby is awesome” • An array is an object [“apple”,“orange”] • A hash is an object { state: “Illinois”,
 zipcode: “60606”} • & many, other types (blocks, lambdas, modules, classes) are also objects

  • 4. Strings • Anything surrounded by • Text based characters, typically representing words “Ruby is fun” “I am a string” “S” • But can also be non-alphabet characters “78” “W2 2Sy” quotes
  • 5. String methods • Start up your terminal • Type ‘irb’ • Let’s look up the docs
  • 6. Arrays bulls = [“Rose”, “Butler”, “Gasol”, “Noah”, “Brooks”] 0 1 2 3 4 • Each element in the array is associated with and referred to by an index bulls[0] = ? bulls[4] = ? • Ordered, integer-indexed collection • Can hold objects such as strings, integers, hashes and other array objects
  • 7. Indexing array = [ “good”, “times”, 2015, “09”, “yup” ] array[0] [1] [2] [3] [4] array[-1][-2][-3][-4][-5]
  • 8. Array methods • Start up your terminal • Type ‘irb’ • Let’s look up the docs (google: ruby docs array)
  • 9. Hashes • Dictionary like collection of unique key-value pairs groceries = { “apples” => 3, “kale” => 1, “chips” => 7 } • Retrieve or create an entry by using its key groceries[“apples”]
 groceries[“ice cream”] = 2
  • 10. Hashes, ctd • Implicit Form
 groceries = {“apples” => 3, “kale” => 1} • Symbols groceries = {apples: 3, kale: 1} style = {color: “red”, size: 3}
  • 11. Hash methods • Start up your terminal • Type ‘irb’ • Let’s look up the docs (try google: ruby 2.2 docs hash)
  • 12. • Everything is an object • Strings are anything in between quotes • Arrays are indexed and start at 0 • Hashes are unique key-value pairs • Check the official ruby docs for methods for each! Recap