let unpack

99 views
Skip to first unread message

vis...@stanford.edu

unread,
Feb 10, 2016, 8:18:54 PM2/10/16
to julia-users
You can normally do

z = (1,2,3)
(a,b,c)  = z

and it will unpack things from z into a,b,c.
However, if you do:

let (a,b,c) = z; a end

it's a syntax error. Is there a way to get the spirit of this unpacking inside a let statement? I don't want permanent assignment in the function (I already get how to do that).
Eg: let a=nothing,b=nothing,c=nothing; (a,b,c) = z; a end seems like a bad choice. There must be some other way....

Thanks!
Vishesh

Mauro

unread,
Feb 11, 2016, 2:58:15 AM2/11/16
to julia...@googlegroups.com
I think this should work. You should file an issue if there is
none yet.

Pablo Zubieta

unread,
Feb 11, 2016, 4:57:51 AM2/11/16
to julia-users
let; (a,b,c) = (1, 2, 3); a end

(note the semicolon) works. But I think it should work as Mauro stated.

Jeff Bezanson

unread,
Feb 11, 2016, 11:18:30 AM2/11/16
to julia...@googlegroups.com
Yes, this should definitely work. I'm a bit surprised it doesn't already.
Reply all
Reply to author
Forward
0 new messages