SlideShare a Scribd company logo
1 of 21
STRINGS AND SYMBOLS




       Sarah Allen
STRINGS
• “I am a string!”
QUOTING STRINGS
• Double quotes interpolate

>> me = "double quotes are awesome”

>> "I am a string withsdouble quotes.n #{me}"

=> "I am a string with double quotes.n double quotes are
  awesome"



• Single quotes don’t interpolate

>> 'I am a string withssingle quotes.n #{me}'

=> "I am a string withssingle quotes.n #{me}"
CONCATENATING STRINGS
first_name = "Yukihiro”

last_name = "Matsumoto”



full_name = first_name + " " + last_name

=> "Yukihiro Matsumoto"
STRING INTERPOLATION
birthday = “January 5th”



“My birthday is #{birthday}”
STRING FORMATTING:
            UPCASE
>> full_name.upcase       >> full_name.upcase!
=> "YUKIHIRO MATSUMOTO”   => "YUKIHIRO MATSUMOTO"


>> full_name              >> full_name
=> "Yukihiro Matsumoto"   => "YUKIHIRO MATSUMOTO"
MORE STRING
            FORMATTING
>> full_name.downcase!
=> "yukihiro matsumoto"


>> full_name.capitalize
=> "Yukihiro matsumoto"


• Making our own title case method:

>> full_name.split.map {|w| w.capitalize}.join(" ")
=> "Yukihiro Matsumoto"


• We can also get title case using regex
ACCESS A STRING’S
             CHARACTERS
>> full_name[2,4]

=> "kihi"

>> full_name[4..6]

=> "hir"
RUBY 1.8
>> name = "Yukihiro”
=> "Yukihiro”
>> name[4]
=> 104
>> name[4].chr
=> "h"
>> name = "        ”

=>"343201223343202223343201204343201241343
  20221”

>> name[2]

=> 147
RUBY 1.9
>>   name = "yukihiro”
=>   "yukihiro”
>>   name[4]
=>   "h”
>>   name = "        ”
=> "          ”
>> name[2]
=> " ”
>> name[0]
=> " "
MODIFYING A STRING
>>   full_name.slice!("hi")
=>   "hi"
>>   full_name
=>   "yukiro matsumoto"

>>   full_name["hi"] = "bye"
=>   "bye"
>>   full_name
=>   "Yukibyero Matsumoto"

>>   full_name[4,2] = "bye"
=>   "bye"
>>   full_name
=>   "Yukibyero Matsumoto"
QUERY A STRING
>> full_name.include?("hi")
=> true


>> full_name.empty?
=> false


>> full_name.size
=> 18


>> full_name.count("o")
=> 3
ITERATE OVER A STRING
             • each_line: process each line in a string
       haiku = "5n7n5n”
       haiku.each_line{|line| puts line}
       5
       7
       5
                                         each_char: process character
 each_byte: process each byte             careful of 1.8.x and 1.9 differences
>> word = "                "            >> word = "         "

=> "            "                       => "        "
                                        >> word.each_char do |s| puts
>> word.each_byte do |                  s
                                        end
s|
puts s
end
227
129
ITERATE USING SPLIT
• returns an array of partial strings exploded at a separator


secret_code = "the black dove flies at night”
secret_code.split(" ").each do |s|

 puts s.reverse
end


eht
kcalb
evod
seilf
ta
thgin
MORE STRING OPERATIONS
full_name = ""
=> ""
full_name << first_name
=> "Yukihiro"
full_name << " "
=> "Yukihiro "
full_name << last_name
=> "Yukihiro Matsumoto"
MORE STRING OPERATIONS

"foo " * 3

=> "foo foo foo "
SYMBOLS
• :i_am_a_symbol
WHAT IS A SYMBOL?

•   A symbol represents a name.

•   Instances of the built-in class Symbol.

•   They efficiently describe names while saving the space
    one would use to generate a string for each naming
    instance.
A SYMBOL IS NOT A
             STRING

    :thing != “thing”


•    However a symbol can be create from a string:
    “thing”.to_sym


•    And a string can be created from a symbol
    :thing.to_s
SYMBOLS ARE IMMUTABLE
•   You can’t change a symbol

•   For example, you can’t append characters to a symbol...once a symbol exists,
    that’s it!

>> :name + :me

NoMethodError: undefined method `+' for :name:Symbol

   from (irb):182

   from :0
>> :name << :me
NoMethodError: undefined method `<<' for :name:Symbol

   from (irb):183

   from :0
SYMBOLS ARE UNIQUE
•    :name is the only symbol object called :name
>>    :name.object_id
=>    68828
>>    :name.object_id
=>    68828

•    “name” is a new String object each time it is instantiated
>>   "name".object_id
=>   2157595700
>>   "name".object_id
=>   2157591380

More Related Content

Similar to Strings and Symbols

Similar to Strings and Symbols (20)

String and string manipulation
String and string manipulationString and string manipulation
String and string manipulation
 
Slides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammersSlides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammers
 
python-strings.pptx
python-strings.pptxpython-strings.pptx
python-strings.pptx
 
Using Regular Expressions and Staying Sane
Using Regular Expressions and Staying SaneUsing Regular Expressions and Staying Sane
Using Regular Expressions and Staying Sane
 
1 the ruby way
1   the ruby way1   the ruby way
1 the ruby way
 
Invertible-syntax 入門
Invertible-syntax 入門Invertible-syntax 入門
Invertible-syntax 入門
 
Haskell for Scala-ists
Haskell for Scala-istsHaskell for Scala-ists
Haskell for Scala-ists
 
Perl_Tutorial_v1
Perl_Tutorial_v1Perl_Tutorial_v1
Perl_Tutorial_v1
 
Perl_Tutorial_v1
Perl_Tutorial_v1Perl_Tutorial_v1
Perl_Tutorial_v1
 
Intro to Perl and Bioperl
Intro to Perl and BioperlIntro to Perl and Bioperl
Intro to Perl and Bioperl
 
Swift Basics
Swift BasicsSwift Basics
Swift Basics
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手
 
Haskell for Scala-ists
Haskell for Scala-istsHaskell for Scala-ists
Haskell for Scala-ists
 
In the Back of Your Mind
In the Back of Your MindIn the Back of Your Mind
In the Back of Your Mind
 
Javascript
JavascriptJavascript
Javascript
 
RedDot Ruby Conf 2014 - Dark side of ruby
RedDot Ruby Conf 2014 - Dark side of ruby RedDot Ruby Conf 2014 - Dark side of ruby
RedDot Ruby Conf 2014 - Dark side of ruby
 
Ruby
RubyRuby
Ruby
 
Java string handling
Java string handlingJava string handling
Java string handling
 
Ohm
OhmOhm
Ohm
 
Basic swift
Basic swiftBasic swift
Basic swift
 

More from Blazing Cloud

Rails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_manyRails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_manyBlazing Cloud
 
Active Record Introduction - 3
Active Record Introduction - 3Active Record Introduction - 3
Active Record Introduction - 3Blazing Cloud
 
Rails Class Intro - 1
Rails Class Intro - 1 Rails Class Intro - 1
Rails Class Intro - 1 Blazing Cloud
 
Your first rails app - 2
 Your first rails app - 2 Your first rails app - 2
Your first rails app - 2Blazing Cloud
 
RSpec Quick Reference
RSpec Quick ReferenceRSpec Quick Reference
RSpec Quick ReferenceBlazing Cloud
 
2day Ruby Class Intro
2day Ruby Class Intro2day Ruby Class Intro
2day Ruby Class IntroBlazing Cloud
 
Interactive Graphics
Interactive GraphicsInteractive Graphics
Interactive GraphicsBlazing Cloud
 
Interactive Graphics w/ Javascript, HTML5 and CSS3
Interactive Graphics w/ Javascript, HTML5 and CSS3Interactive Graphics w/ Javascript, HTML5 and CSS3
Interactive Graphics w/ Javascript, HTML5 and CSS3Blazing Cloud
 
Intro to Ruby (and RSpec)
Intro to Ruby (and RSpec)Intro to Ruby (and RSpec)
Intro to Ruby (and RSpec)Blazing Cloud
 
What you don't know (yet)
What you don't know (yet)What you don't know (yet)
What you don't know (yet)Blazing Cloud
 
Introduction to Rails
Introduction to RailsIntroduction to Rails
Introduction to RailsBlazing Cloud
 
Ruby on Rails Class intro
Ruby on Rails Class introRuby on Rails Class intro
Ruby on Rails Class introBlazing Cloud
 
Ruby on rails toolbox
Ruby on rails toolboxRuby on rails toolbox
Ruby on rails toolboxBlazing Cloud
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentBlazing Cloud
 

More from Blazing Cloud (20)

Rails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_manyRails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_many
 
Active Record Introduction - 3
Active Record Introduction - 3Active Record Introduction - 3
Active Record Introduction - 3
 
Rails Class Intro - 1
Rails Class Intro - 1 Rails Class Intro - 1
Rails Class Intro - 1
 
Your first rails app - 2
 Your first rails app - 2 Your first rails app - 2
Your first rails app - 2
 
RSpec Quick Reference
RSpec Quick ReferenceRSpec Quick Reference
RSpec Quick Reference
 
Extending rails
Extending railsExtending rails
Extending rails
 
2day Ruby Class Intro
2day Ruby Class Intro2day Ruby Class Intro
2day Ruby Class Intro
 
Mobile Lean UX
Mobile Lean UXMobile Lean UX
Mobile Lean UX
 
Interactive Graphics
Interactive GraphicsInteractive Graphics
Interactive Graphics
 
Interactive Graphics w/ Javascript, HTML5 and CSS3
Interactive Graphics w/ Javascript, HTML5 and CSS3Interactive Graphics w/ Javascript, HTML5 and CSS3
Interactive Graphics w/ Javascript, HTML5 and CSS3
 
Form helpers
Form helpersForm helpers
Form helpers
 
Intro to Ruby (and RSpec)
Intro to Ruby (and RSpec)Intro to Ruby (and RSpec)
Intro to Ruby (and RSpec)
 
What you don't know (yet)
What you don't know (yet)What you don't know (yet)
What you don't know (yet)
 
Introduction to Rails
Introduction to RailsIntroduction to Rails
Introduction to Rails
 
ActiveRecord
ActiveRecordActiveRecord
ActiveRecord
 
Ruby on Rails Class intro
Ruby on Rails Class introRuby on Rails Class intro
Ruby on Rails Class intro
 
Ruby on rails toolbox
Ruby on rails toolboxRuby on rails toolbox
Ruby on rails toolbox
 
Routes Controllers
Routes ControllersRoutes Controllers
Routes Controllers
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Active Record
Active RecordActive Record
Active Record
 

Recently uploaded

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Recently uploaded (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

Strings and Symbols

  • 1. STRINGS AND SYMBOLS Sarah Allen
  • 2. STRINGS • “I am a string!”
  • 3. QUOTING STRINGS • Double quotes interpolate >> me = "double quotes are awesome” >> "I am a string withsdouble quotes.n #{me}" => "I am a string with double quotes.n double quotes are awesome" • Single quotes don’t interpolate >> 'I am a string withssingle quotes.n #{me}' => "I am a string withssingle quotes.n #{me}"
  • 4. CONCATENATING STRINGS first_name = "Yukihiro” last_name = "Matsumoto” full_name = first_name + " " + last_name => "Yukihiro Matsumoto"
  • 5. STRING INTERPOLATION birthday = “January 5th” “My birthday is #{birthday}”
  • 6. STRING FORMATTING: UPCASE >> full_name.upcase >> full_name.upcase! => "YUKIHIRO MATSUMOTO” => "YUKIHIRO MATSUMOTO" >> full_name >> full_name => "Yukihiro Matsumoto" => "YUKIHIRO MATSUMOTO"
  • 7. MORE STRING FORMATTING >> full_name.downcase! => "yukihiro matsumoto" >> full_name.capitalize => "Yukihiro matsumoto" • Making our own title case method: >> full_name.split.map {|w| w.capitalize}.join(" ") => "Yukihiro Matsumoto" • We can also get title case using regex
  • 8. ACCESS A STRING’S CHARACTERS >> full_name[2,4] => "kihi" >> full_name[4..6] => "hir"
  • 9. RUBY 1.8 >> name = "Yukihiro” => "Yukihiro” >> name[4] => 104 >> name[4].chr => "h" >> name = " ” =>"343201223343202223343201204343201241343 20221” >> name[2] => 147
  • 10. RUBY 1.9 >> name = "yukihiro” => "yukihiro” >> name[4] => "h” >> name = " ” => " ” >> name[2] => " ” >> name[0] => " "
  • 11. MODIFYING A STRING >> full_name.slice!("hi") => "hi" >> full_name => "yukiro matsumoto" >> full_name["hi"] = "bye" => "bye" >> full_name => "Yukibyero Matsumoto" >> full_name[4,2] = "bye" => "bye" >> full_name => "Yukibyero Matsumoto"
  • 12. QUERY A STRING >> full_name.include?("hi") => true >> full_name.empty? => false >> full_name.size => 18 >> full_name.count("o") => 3
  • 13. ITERATE OVER A STRING • each_line: process each line in a string haiku = "5n7n5n” haiku.each_line{|line| puts line} 5 7 5  each_char: process character  each_byte: process each byte careful of 1.8.x and 1.9 differences >> word = " " >> word = " " => " " => " " >> word.each_char do |s| puts >> word.each_byte do | s end s| puts s end 227 129
  • 14. ITERATE USING SPLIT • returns an array of partial strings exploded at a separator secret_code = "the black dove flies at night” secret_code.split(" ").each do |s| puts s.reverse end eht kcalb evod seilf ta thgin
  • 15. MORE STRING OPERATIONS full_name = "" => "" full_name << first_name => "Yukihiro" full_name << " " => "Yukihiro " full_name << last_name => "Yukihiro Matsumoto"
  • 16. MORE STRING OPERATIONS "foo " * 3 => "foo foo foo "
  • 18. WHAT IS A SYMBOL? • A symbol represents a name. • Instances of the built-in class Symbol. • They efficiently describe names while saving the space one would use to generate a string for each naming instance.
  • 19. A SYMBOL IS NOT A STRING :thing != “thing” • However a symbol can be create from a string: “thing”.to_sym • And a string can be created from a symbol :thing.to_s
  • 20. SYMBOLS ARE IMMUTABLE • You can’t change a symbol • For example, you can’t append characters to a symbol...once a symbol exists, that’s it! >> :name + :me NoMethodError: undefined method `+' for :name:Symbol from (irb):182 from :0 >> :name << :me NoMethodError: undefined method `<<' for :name:Symbol from (irb):183 from :0
  • 21. SYMBOLS ARE UNIQUE • :name is the only symbol object called :name >> :name.object_id => 68828 >> :name.object_id => 68828 • “name” is a new String object each time it is instantiated >> "name".object_id => 2157595700 >> "name".object_id => 2157591380

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. There is no title case method in ruby...we can make our own \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n