Why assignment operators return the right-hand-side

Regarding this argument, I don’t really find it makes much sense to me.

When you see someone write

x = (;a, b) = (;a=1, b=2, c=3, d=4)

do you really read that as

temp = (;a=1, b=2, c=3, d=4)
(;a, b) = temp
x = temp

?

For me, the code realllllly seems to suggest something more of the form

(;a, b) = (;a=1, b=2, c=3, d=4)
x = (;a, b)

Since we’re taught that (;a,b) = coll is shorthand for a, b = coll.a, coll.b, it seems straightforward to me that writing x = (;a, b) = coll would be x = ((;a,b) = coll) which is x = ((a, b) = coll.a, coll.b).


Similarly, I see

x = y::Float64 = 1

as absolutely saying x = (y::Float64 = 1) and so suggesting both x and y should be Float64.

2 Likes