CommandHelper

CommandHelper

46.5k Downloads

Function for copying a variable

LadyCailinBot opened this issue ยท 1 comments

commented

CMDHELPER-3021 - Reported by VergilPrime

@var = import('something') links those two bits of data, and that's fine. But theres no non-hokey way to make a simple copy of whatever is on the right of the "=" without linking them. Say I want to flip an array upside down without altering the original, or round a number without losing the whole coordinate.

What I think we need is something like @var = copy(import('something')), so all copy() needs to do is return the value of whatever is inside without linking it.

commented

Comment by LadyCailin

This only matters with arrays, for which a mechanism like you're wanting already exists. @copy = import('something')[]. This will copy the reference to the array, or you can copy it before you export it to begin with, depending on your needs.