First: Reference variable
Since i'm a coder, i still remember when i learn about variable: i must learn what is reference var and what is storage var.
In some program languages, a is storage var, b is reference var.
And if the storage var (a) changes, the reference var (b) changes too.
However, in jass, both a and b is storage var! Then rewrite a with the other integer does not change b
And what about i?
Simple test:
The integer displays it's 1.
So the basic law here is:
- JASS have no reference variable.
Althought it's very simple, we still need to know that! Because it's basic and it has utmost influence!
Second: How to convert a variable to another type?
Like Nes said, there are native types and non-native types
And something is more interesting:
Result is:
1
0
And advance knowledge with the types extends native type:
Ex:
can use like this
Since i'm a coder, i still remember when i learn about variable: i must learn what is reference var and what is storage var.
JASS:
globals
integer a
integer b
endglobals
function SetBValue takes integer i returns nothing
set a=i
set b=a
set i=i+1
endfunction
In some program languages, a is storage var, b is reference var.
And if the storage var (a) changes, the reference var (b) changes too.
However, in jass, both a and b is storage var! Then rewrite a with the other integer does not change b
And what about i?
Simple test:
JASS:
function TestSetValue takes nothing returns nothing
local integer test=1
call SetBValue(test)
call BJDebug(I2S(test))
endfunction
The integer displays it's 1.
So the basic law here is:
- JASS have no reference variable.
Althought it's very simple, we still need to know that! Because it's basic and it has utmost influence!
Second: How to convert a variable to another type?
Like Nes said, there are native types and non-native types
the list of primitives would include
boolean
integer
real
code
handle
string
I2R
|
I2S
|
R2I
|
R2S
|
S2I
|
S2R
|
2 -> 2.0 | 3 -> "3" | 2.8 -> 2 | 2.1 -> "2.100" | "3.12345" -> 3 | "5.123456" -> 5.123 |
And something is more interesting:
JASS:
function TestEvaluate takes nothing returns nothing
local integer test=SetBValue
call BJDebug(I2S(test))
set test=abcfunc
call BJDebug(I2S(test))
endfunction
1
0
And advance knowledge with the types extends native type:
Ex:
native function GetHandleId takes handle h returns integer
can use like this
call GetHandleId(TriggerUnit)