You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
my temperature = 37,
pressure = 19,
balloonCount = 65;
Note that this is incompatible with both Perl 5/6 and Python 2/3. Both of these families of languages prefer what we might call "parallel assignment" when declaring:
We find a friend in JavaScript, though, and model this feature on it:
var temperature = 37,
pressure = 19,
balloonCount = 65;
The biggest difference in practice is that in serial assignment, earlier variables in the same declaration can already be used when assigning to later ones:
my temperature = 37,
pressure = 19,
ratio = temperature / pressure; # didn't even try to get the units right
Oh, and it's also fine to omit the assignment, as usual, and get None.
We're allowed — encouraged, even — to create any kind of API for declaring variables to make this work. It's considered a part of the challenge that we use the my keyword even for this new serial-assignment declaration. Of course declaring only one variable should still work rather than, say, cause a parsing rule conflict.
The text was updated successfully, but these errors were encountered:
The biggest difference in practice is that in serial assignment, earlier variables in the same declaration can already be used when assigning to later ones
#279 (correctly) states that if we went ahead and made my into a term, then this issue would become kinda moot. More exactly, this is now definitely a compile-time error:
Like this:
Note that this is incompatible with both Perl 5/6 and Python 2/3. Both of these families of languages prefer what we might call "parallel assignment" when declaring:
We find a friend in JavaScript, though, and model this feature on it:
The biggest difference in practice is that in serial assignment, earlier variables in the same declaration can already be used when assigning to later ones:
Oh, and it's also fine to omit the assignment, as usual, and get
None
.We're allowed — encouraged, even — to create any kind of API for declaring variables to make this work. It's considered a part of the challenge that we use the
my
keyword even for this new serial-assignment declaration. Of course declaring only one variable should still work rather than, say, cause a parsing rule conflict.The text was updated successfully, but these errors were encountered: