Solving Embarrassingly Obvious Problems in Erlang (2019)
blog.usejournal.com1 pointsby draegtun0 comments
$hash1->{key1}{key2}
And if `hash1` was a hash (instead of a hashref) then it's just this: $hash1{key1}{key2}
The `%{}` de-reference you mention later is only when you have an operation that requires a hash, for eg: keys %{$hash1{key1}}
And for kstrauser example later in Python... hash1["hash_name"]["array_name"][3]
the equivalent in Perl would be... $hash1{hash_name}{array_name}[3]
I find having {} & [] as lookup keys for their types is not only more explicit but also safer/correct. # perl
my $x = do {
…
5
};
;; Rebol/Red
x: do [
…
5
] : unless ( ? quot -- res ) swap [ drop ] [ call ] if ; inline
Rebol/Red... unless: func [expr block] [either expr [] block] user: [name: "John Doe" birth-date: 1970-01-01 account-balance: $1000.01]
[1] https://en.wikipedia.org/wiki/Rebol loop 10 [
print "hello" ;; prints "hello" 10 times
]
repeat n 10 [
print n ;; prints 1 to 10
]
forever [
print "hello" ;; print "hello" forever!
]
Even Ruby's trailing blocks syntax are an homage to Perl's block list subroutines: