Ask A Question

Notifications

You’re not receiving notifications from this thread.

Hashes in Ruby Discussion

Discussion for Hashes in Ruby

If we use h = HashWithIndifferentAccess.new({key: "value"}) it will allow us to access the value through both h[:key] and h["key"].

Reply

Hey Yago, while this is true, HashWithIndifferentAccess is only available via ActiveSupport. This section of the learning path is focused purely on Ruby.

Reply

Thanks Collin! I like the #dig method! : )

Reply

It's a good one for sure! ;)

Reply

Absolutely, HashWithIndifferentAccess is handy for treating keys as either symbols or strings. It provides flexibility when accessing values, making your code more user-friendly and versatile.

Reply

I am coming from javascript and most of the concepts are similar but you do an amazing job explaining everything. Good job!

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 81,842+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.