in reply to Re^2: RFC: Destructuring Assignment (aka Unpacking aka Type Patterns) in pure Perl
in thread RFC: Destructuring Assignment (aka Unpacking aka Type Patterns) in pure Perl
Sort of like your slice, but you also can provide default values if things are missing. E.g. if arg_map didn't have anything at the key :foo the variable foo would get be the string "foo missing".
(let [{:keys [foo bar] :or {foo "foo missing"}} arg_map] ;; ... )
You'd prossibly need something like my $foo = exists $arg_map{foo} ? $arg_map{foo} : "foo missing" and you'd need to do each variable separately. (I've not messed with clojure in long enough that I'm probably explaining this poorly, to boot . . .)
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: RFC: Destructuring Assignment (aka Unpacking aka Type Patterns) in pure Perl
by LanX (Saint) on Jul 04, 2020 at 10:35 UTC |