For the given variable assignment from array:
a,b,c,d,e = [ "foo","bar","discard","discard","blah" ]
Is there a way to only have a, b, and e assigned and discard c and d? Is there an undef like in perl (Perl assignment with a dummy placeholder).
Yes.
a,b,_,_,e = [ "foo","bar","discard","discard","blah" ]
You can use the splat operator.
a,b,*,e = ["foo","bar",nil,nil,"blah"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With