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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Saurabh Bhatia
April 25, 2013
Technology
64
0
Share
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
コーポレートサイトのアクセシビリティ改善とJIS準拠への実践
lycorptech_jp
PRO
2
120
Claude Code で使える DuckDB Skills を試してみた / DuckDB Skills and Claude Code
masahirokawahara
2
2.2k
サプライチェーン攻撃への備えについて考えている #湘なんか
stefafafan
3
2.3k
論文紹介:Pixal3D (SIGGRAPH 2026)
tenten0727
0
700
[みん強]AIの価値を最大化するデータ基盤戦略:Self-Service型Data Meshへの転換とAgentic AI Meshに向けた取り組み with Snowflake他
y_matsubara
1
180
【新卒研修】ライブデモ + compose.yaml読解_講義資料
dip_tech
PRO
0
130
Fラン学生が考える、AI時代のデザインに執着した突破口
husengs7
1
240
AIコーディングエージェントの活用で、コードは静かに肥大化した
yosukeshinoda
1
240
TypeScriptはどのようにどこまで推論できるのか ─ とにかく as は禁止で
ypresto
2
360
開発にAIを組織として取り入れる一歩目とその後
yujishibuya
0
190
コーディングエージェントはTypeScriptの 型エラーをどう自己修正しているのか
melonps
3
390
ルール・ロール・ツールを創る / Creating Rules, Roles and Tools
ks91
PRO
0
150
Featured
See All Featured
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
530
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
530
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
180
The Invisible Side of Design
smashingmag
302
52k
Exploring anti-patterns in Rails
aemeredith
3
360
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.2k
Designing Powerful Visuals for Engaging Learning
tmiket
1
370
Tell your own story through comics
letsgokoyo
1
930
Deep Space Network (abreviated)
tonyrice
0
150
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.9k
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] }]