badfitz67
|
  |
| Joined: 03 Jun 2010 |
| Total Posts: 13165 |
|
|
| 14 Dec 2016 02:28 PM |
http://wiki.roblox.com/index.php?title=Vector2#X
Why is this?
Y is a vowel in about the same way that France historically is a republic. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 14 Dec 2016 02:31 PM |
Because there's a lot that could go wrong if it weren't.
Here's a snippet from Stravant which explains it really clearly: "Because, it's impossible to make an API that works with it otherwise unless you're working in a language like C++ with a type-system that tracks const-ness.
Considering the following situation: local a # #}##for i = 1, 100000 do a[i] = somePart.Position end
The possible outcomes: 1) A contains 100000 references to the same Vector3 object, that is the internal Vector3 representing the position of the part. That part can now change position without warning from anywhere in your project, without you knowing why it happened, because someone somewhere accidentally changed the value of a Vector3. You can see how that might be frustrating. Also, this requires having the part listening for changes on that Vector3 object to know when to update because the Vector3 changed.
2) A contains 100000 references to different Vector3 objects, that are copies of the position at the time. This is moderately better than the prior situation, but you can still modify any of these Vector3s from anywhere in the project and have it change elsewhere without warning. Also, it's confusing because now the part is no longer moved by editing it's position's components, which is probably why you wanted the mutability feature in the first place." |
|
|
| Report Abuse |
|
|
badfitz67
|
  |
| Joined: 03 Jun 2010 |
| Total Posts: 13165 |
|
|
| 14 Dec 2016 02:48 PM |
i'm probably just too used to using a vector2 class/module while using love2D and being able to change the x and y values
Y is a vowel in about the same way that France historically is a republic. |
|
|
| Report Abuse |
|
|
|
| 14 Dec 2016 10:56 PM |
You can still write to Y only:
Vec2 = Vector2.new(Vec2.x, 5)
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 14 Dec 2016 11:35 PM |
Thats setting a vector, not writing to it.
You can't do this:
Vec2.x,Vec2.y = 5,5
|
|
|
| Report Abuse |
|
|