- Home /
Dictionary.TryGetValue for js
I'm trying to use a dictionary's TryGetValue in js, but i would need to pass a variable by reference.
though it seems js cant use 'ref' or 'out' to pass by reference. line in questions is like this:
var containerChunk : Chunk;
chunks.TryGetValue(pos, containerChunk);
i know js does alot of things automatically, but is that containerChunk var being passed by ref automatically by any chance? or do i need to break this line down like:
if(chunks.ContainsKey(pos))
{
containerChunk = chunks[pos];
}
or is there some way to pass by ref in js that i don't know about?
Answer by Eric5h5 · Dec 16, 2015 at 04:39 AM
If a variable needs to be ref or out, then it is automatically, or else standard Unity functions such as Physics.Raycast (i.e. out hitInfo) wouldn't work.
Your answer
![](https://koobas.hobune.stream/wayback/20220612052816im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
An instance of type 'TurretControl' is required to access non static member 'Shoot'. 1 Answer
Can I get a reference (not a copy) to a string from a script? 2 Answers
Quickly access specific list elements in a constantly changing list 1 Answer
UnityScript - Class reference 1 Answer
Reference JS string to C# 1 Answer