# Comments refer to wrong vectors returned by method using ToRef

**URL:** <https://forum.babylonjs.com/t/comments-refer-to-wrong-vectors-returned-by-method-using-toref/34093>\
**Category:** Bugs\
**Tags:** api\
**Created:** [September 21, 2022, 10:34am UTC](https://forum.babylonjs.com/t/comments-refer-to-wrong-vectors-returned-by-method-using-toref/34093 "2022-09-21T10:34:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [September 21, 2022, 10:34am UTC](https://forum.babylonjs.com/t/comments-refer-to-wrong-vectors-returned-by-method-using-toref/34093/1 "2022-09-21T10:34:32Z")

</div>

This is one example, there are several others with the same error in math.vector.ts

```javascript
/**
     * Negate the current Vector3 and stores the result in the given vector "result" coordinates
     * Example Playground https://playground.babylonjs.com/#R1F8YU#37
     * @param result defines the Vector3 object where to store the result
     * @returns the current Vector3
     */
    public negateToRef(result: Vector3): Vector3 {
        return result.copyFromFloats(this._x * -1, this._y * -1, this._z * -1);
    }

```

You can see in this PG [Babylon.js Playground](https://playground.babylonjs.com/#E70DXA)

that it returns the result vector not the current vector.

```javascript
current vector {X: 1 Y: 2 Z: 3}
result vector {X: -1 Y: -2 Z: -3}
returned vector {X: -1 Y: -2 Z: -3} 

```

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [September 21, 2022, 10:36am UTC](https://forum.babylonjs.com/t/comments-refer-to-wrong-vectors-returned-by-method-using-toref/34093/2 "2022-09-21T10:36:49Z")

</div>

That’s an interesting catch. I would expect these function to return the result in any way (because chaining makes little sense when using ToRef). So I guess it is just a matter of changing the docs. Unless you think it should return the original?

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [September 21, 2022, 10:44am UTC](https://forum.babylonjs.com/t/comments-refer-to-wrong-vectors-returned-by-method-using-toref/34093/3 "2022-09-21T10:44:54Z")

</div>

> [@RaananW](#):
>
> Unless you think it should return the original?

Was wondering which way it should go. Happy for docs to be changed.

I am doing a PR on that file, shall I change comments to returns result where I find errors?

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [September 21, 2022, 10:47am UTC](https://forum.babylonjs.com/t/comments-refer-to-wrong-vectors-returned-by-method-using-toref/34093/4 "2022-09-21T10:47:31Z")

</div>

Please do. I see that as the expected behavior
