Can you not modify function parameters like this in verse?

Follow-up question. Is verse pass by value or pass by reference?

It needs a return type of int not void

Pretend it’s void that was just a dumb mistake

image
The void wasn’t the issue though
It gives the error " The assignment’s left hand expression type int cannot be assigned to(3509)
A:int"

Yeah, never ran into this before, but looks like its a reference and can’t be modified. But this works:

TestFunction(SomeValue:int):int=
{
    var changedValue:int = SomeValue + 5
    return changedValue
}
1 Like

Ok cool, I thought that that’s what I would have to do but wanted to see if there was an alternative. Thanks!

It looks like you are attempting to modify the parameter that is passed in to the function itself, by using a style similar to what other languages would have if you could pass params via reference. A reference is simply an address that points to a different variable. So in languages that support stuff like this, you can modify the original parameter that is passed in directly.

I do not believe Verse supports this, and instead uses pass by copy. Therefore you just need to manipulate the parameter however you want using another temporary variable to store the result, and then return that temporary variable.

An additional note - It seems as though this might be a feature planned for the future:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.