Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Symbols and Hashes Intro
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Saurabh Bhatia
April 25, 2013
Technology
65
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Symbols and Hashes Intro
Intro to Symbols and Hashes
Saurabh Bhatia
April 25, 2013
More Decks by Saurabh Bhatia
See All by Saurabh Bhatia
Barrister RPC
thewub
0
460
RulingOrbit
thewub
0
390
Rails API
thewub
0
450
Cloud Primer
thewub
1
420
Other Decks in Technology
See All in Technology
なぜ、あなたのエージェントは言うことを聞かないのか
segavvy
1
380
副作用のある Lambda でも Lambda Power Tuning は使えるのか / lambda-power-tuning-side-effects
koukihosaka
2
150
書籍セキュアAPIについて
riiimparm
0
260
探索・可視化・自動化を一本化 Amazon Quickでデータ活用スピードを上げる方法
koheiyoshikawa
0
180
JAWS_ICEBERG_BASECAMP
iqbocchi
2
110
GoでCコンパイラを作った話
repunit
0
150
AIコード生成×サプライチェーン攻撃 — PHPが直面する“二重の信頼問題
shinyasaita
0
460
Webの技術とガジェットで子どもも大人も楽しめるワクワク体験を提供する / Qiita Tech Festa Day 2026
you
PRO
1
200
AI時代におけるエンジニアの新たな役割──FDEとクオリアの探求/登壇資料(戸井田 裕貴)
hacobu
PRO
0
330
変更し続けられるシステムをどう保つか — AI時代のSSoTという設計原則
kawauso
1
1.1k
プロダクト開発組織の現在地(Ver.2026/07) / product-organization
kaonavi
0
410
AI時代こそ、スケールしないことをしよう -「作る人」から「なぜ作るか」を考える人へ / Do Things That Don't Scale in the AI Era — From How to Why
kaminashi
1
110
Featured
See All Featured
Skip the Path - Find Your Career Trail
mkilby
1
170
Ethics towards AI in product and experience design
skipperchong
2
330
BBQ
matthewcrist
89
10k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.7k
Typedesign – Prime Four
hannesfritz
42
3.1k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
320
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
620
How to train your dragon (web standard)
notwaldorf
97
6.7k
Between Models and Reality
mayunak
4
380
So, you think you're a good person
axbom
PRO
2
2.1k
Transcript
Strings and Hashes
What is it ? • Symbol is something used to
represent a string. • A more memory efficient and descriptive way to do things.
How does it look ? Colon followed by a non-quoted
string - :symbol Or Colon followed by quoted string - :'this is another symbol'
Assigning stuff to symbols • :my_symbol = “foo_bar” - wrong
• my_symbol = :foo_bar – right • attr_accessor :foo_bar • my_symbol = :foo_bar.to_s
Symbols are immutable
hash • Data structure – collection of key value pairs
• Indexing via keys of object _type • Randomly ordered
What does it look like ? • animals = Hash.new
• animals["dog"] = "bark" • pry(main)> animals => {"dog"=>"bark", "cat"=>"purr"}
• Iterating over an array • animal_farm.each do |a| puts
a end • Iterating over a hash • animals.each do |k,v| puts “#{k} and #{v} end
exercise • Create a hash to represent currencies eg USA
=> usd , UK => gbp, JAPAN => yen • Display all the currencies • Replace all the name of countries with their short codes eg US -> US, JAPAN –> JP, UK -> UK
Solution • currencies = { “USA” => “usd” , “UK”
=> “gbp”, “JAPAN” => “yen” } • new_currencies = {"US" => "usd", "UK" => "gbp", “JP” => “yen”} • Hash[currencies.map {|k, v| [new_currencies[k], v] }]