Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Symbols and Hashes Intro
Search
Saurabh Bhatia
April 25, 2013
Technology
68
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
470
RulingOrbit
thewub
0
390
Rails API
thewub
0
460
Cloud Primer
thewub
1
420
Other Decks in Technology
See All in Technology
SQL文一行も書けない人事がCortexもろもろを使って人事業務を楽にしてみる
ponponmikankan
1
240
品質と信頼性を地続きにする
grimoh
0
210
人間はどの意思決定を手放せるのか
kawasima
14
5.6k
Claude Code本って、 読む必要あるの?
oikon48
2
450
2026/09/10 Spring Bootから Jakarta EE/MicroProfileへの移行
megascus
0
360
【技術的負債conf】事業成長に伴う技術的負債の説明責任とAIによるモニタリング、認知的負債について
i35_267
2
900
登壇の自信を奪う3匹のオバケ / 3 Ghosts That Rob You of Your Confidence in Public Speaking
pauli
8
830
30座EKS, 180次升級淬煉的EKS Upgrade Skill 的歷程
eric8230
0
120
AIを活用するために決めた "やらないこと" - 価値に注目する / Not betting on AI
soudai
PRO
1
500
アプリログインとWeb認証基盤をつなぐ ASWebAuthenticationSession 作法
shimastripe
1
310
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
3
490
omasushiというライブラリを作った
polidog
PRO
0
220
Featured
See All Featured
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
480
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
230
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
It's Worth the Effort
3n
188
29k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Six Lessons from altMBA
skipperchong
29
4.5k
What's in a price? How to price your products and services
michaelherold
247
13k
Everyday Curiosity
cassininazir
0
320
Site-Speed That Sticks
csswizardry
13
1.5k
WENDY [Excerpt]
tessaabrams
13
39k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
380
Joys of Absence: A Defence of Solitary Play
codingconduct
1
510
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] }]