ThreadSky
About ThreadSky
Log In
enderahmetyurt.com
β’
93 days ago
I like to use `dig` in Ruby, but there are many ways to get a value of Hash key in Ruby. I wrote something. π #ruby #programming
https://enderahmetyurt.com/posts/accessing-values-in-a-hash-with-dig-in-ruby-differences-and-alternatives/
Comments
Log in
with your Bluesky account to leave a comment
[β]
bradgessler.com
β’
92 days ago
Good overview!
I consider `dig` unsafe when I need to explode code because a key is missing.
Pattern matching is handy too, like `{foo: 1, bar: { buzz: :buzz }} => bar: {buzz:}` to extract `buzz`, for more complex hash extractions.
Useful for protocol programming.
1
1
reply
[β]
enderahmetyurt.com
β’
92 days ago
Thank you π I didnt use pattern matching before. Iβll consider it while fetching a value next time.
1
reply
[β]
nirebu.bsky.social
β’
92 days ago
One thing I love about dig is it's performance. It "digs" entirely in C, without allocating anything in the meantime.
Pretty useful when accessing thousands of deep hashes.
2
reply
[β]
adrianthedev.com
β’
92 days ago
Awesome article! Itβs good to know that we have options π
1
1
reply
[β]
enderahmetyurt.com
β’
92 days ago
Thank you man. You know that we have many options to do one thing in Ruby π€
2
reply
Posting Rules
Be respectful to others
No spam or self-promotion
Stay on topic
Follow Bluesky's terms of service
×
Reply
Post Reply
Comments
I consider `dig` unsafe when I need to explode code because a key is missing.
Pattern matching is handy too, like `{foo: 1, bar: { buzz: :buzz }} => bar: {buzz:}` to extract `buzz`, for more complex hash extractions.
Useful for protocol programming.
Pretty useful when accessing thousands of deep hashes.