As always, this is why it's important to understand what the language is doing before calling somebody wrong 🙂
Y'see, no variable in Ruby ever holds the object in question, but instead holds a reference to the object. a, b = b, a tells Ruby to place a reference to whatever is referenced by b at the time of invocation inside of the reference a, and whatever is referenced by a at the time of invocation inside of the reference b. No array construction, no invisible intermediary variable, just happy-go-lucky references, reassigning themselves to the underlying addressed memory locations.
As I said, I am not sure what Ruby does and how this parallel assignment really works under the hood.
For the python example (and this was the main focus), my statement holds :-). It's a construction of an array (list), that is assigned to another list and afterwards deconstructed.
Good try, but no. "You both fail" is geared quite equally toward two intended audiences. Again, understand what the language is doing before you call someone wrong 😊
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
As always, this is why it's important to understand what the language is doing before calling somebody wrong 🙂
Y'see, no variable in Ruby ever holds the object in question, but instead holds a reference to the object.
a, b = b, a
tells Ruby to place a reference to whatever is referenced byb
at the time of invocation inside of the referencea
, and whatever is referenced bya
at the time of invocation inside of the referenceb
. No array construction, no invisible intermediary variable, just happy-go-lucky references, reassigning themselves to the underlying addressed memory locations.Thx 4 the patronization tho! 💖💖😘
As I said, I am not sure what Ruby does and how this parallel assignment really works under the hood.
For the python example (and this was the main focus), my statement holds :-). It's a construction of an array (list), that is assigned to another list and afterwards deconstructed.
Good try, but no. "You both fail" is geared quite equally toward two intended audiences. Again, understand what the language is doing before you call someone wrong 😊