• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

[vJASS] Even more vJASS

Status
Not open for further replies.
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