How many tokens would an array take up? #123
-
In the documentation it says that a variable are counted as 1 token. I was just wondering whether an array would use 1 token or its length? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
If you write |
Beta Was this translation helpful? Give feedback.
-
There's a line in the TokenCounter script |
Beta Was this translation helpful? Give feedback.
If you write
int[] array = { 1, 2, 3 };
for example it will count as 9 tokens. The breakdown of counted tokens is:IntKeyword int
OpenBracketToken [
OmittedArraySizeExpressionToken (hmm I should maybe remove this one, I didn't notice this before)
IdentifierToken array
EqualsToken =
OpenBraceToken {
NumericLiteralToken 1
NumericLiteralToken 2
NumericLiteralToken 3