• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[vJASS] Even more vJASS

Status
Not open for further replies.
Level 16
Joined
Mar 3, 2006
Messages
1,564
Now that I know about structs, methods, library, scope, statics, private and public and all this basic things.

I need to learn the rest so the first thing I am asking, what is "operator" I can't understand a word from the JassHelper manual, could someone give me a detailed explanation, please ?
 
Level 12
Joined
Oct 16, 2010
Messages
680
operators are method calls built inside the program language

operators are : " = " " < " " > " " != " etc..

with operator keyword, you can make own operators like a method call

eg:

method operator i2 takes nothing returns integer
return i*i
endmethod

method operator i2= takes integer j returns nothing
set i = j/i
endmethod

in the egsample I made an operator i2 and a i2= . See how it ease the syntax

without operator:

set c = SquareRoot(i*i + i*i)
set i = j/i

with operators:

set c = SquareRoot(i2+i2)
set i2=j

its not a big difference here but can do realy comlex things with it

just think of it that the " i " represents something long and complicated

----------
method operator x2 takes nothing returns integer
return GetUnitX(struct.someunit)*GetUnitX(struct.someunit)
endmethod

method operator y2 takes nothing returns integer
return GetUnitY(struct.someunit)*GetUnitY(struct.someunit)
endmethod

without operator:

c = SquareRoot(GetUnitX(struct.someunit)*GetUnitX(struct.someunit)+GetUnitY(struct.someunit)*GetUnitY(struct.someunit))

with operator:

c = SquareRoot(x2+y2)

its only a basic thing you can use operators for. try out some thing
 
Status
Not open for further replies.
Top