Created
October 19, 2015 01:00
-
-
Save gbpereira/5066cff8448ee5508588 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inicializando hash | |
hash = {} # inicializa um hash vazio | |
hash = Hash.new # inicializa um hash vazio | |
hash = {one: 1, two: 2} # inicializa um hash com valores | |
# adicionando valores | |
hash[:word] = 'seccomp' | |
# acessando valores | |
hash[:word] | |
#=> "seccomp" | |
# alterando valores | |
hash[:word] = 'seccomp 2015' | |
#=> {:one=>1, :two=>2 :seccomp=>"seccomp 2015"} | |
# também podem conter elementos de diferentes tipos de dados | |
hash = { int: 1, float: 1.0, range: (1..4), arr: [1, 2, 3], h: {a: 'a'} } | |
#=> => {:int=>1, :float=>1.0, :range=>1..4, :arr=>[1, 2, 3], :h=>{:a=>"a"}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment