[ruby/en] clarify alternate hash syntax

This commit is contained in:
FireIsGood 2024-11-12 20:26:27 -08:00
parent 572827b39f
commit 350dd22db2
No known key found for this signature in database
GPG Key ID: 0ACFEAD4981C92DF

View File

@ -233,11 +233,14 @@ hash['number'] #=> 5
# Asking a hash for a key that doesn't exist returns nil.
hash['nothing here'] #=> nil
# When using symbols for keys in a hash, you can use an alternate syntax.
# When using symbols for keys in a hash, you can use an alternate syntax similar
# to JavaScript.
# key => value
hash = { :defcon => 3, :action => true }
hash.keys #=> [:defcon, :action]
# key: value
hash = { defcon: 3, action: true }
hash.keys #=> [:defcon, :action]