Function problem

Rabarber

You can change this now in User CP.
Reaction score
94
I made a function, after reading Vexorians guide, but JassCraft returns a few errors;
Code:
function b2s takes boolean b returns string

if b == true then
         return "true"
else
         return "false"
endif
endfunction

What's wrong, exactly?
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Code:
function b2s takes boolean b returns string
if b == true then
         return "false"
else
         return "false"
endif
endfunction

You forgot an " after the second false. BTW, shouldn't the first "false" be "true"?

You can also remove the '== true', it serves no purpose.
 

SFilip

Gone but not forgotten
Reaction score
634
what's the point of using this function? all i see here is returning "false"...shouldn't the first return be "true"?
 

Rabarber

You can change this now in User CP.
Reaction score
94
I mappened to make something wrong, that's all. It's fixed now.
 
C

CryptWizard

Guest
You must have an return that isn't inside an if, otherwise it returns an error, so:
Code:
function B2S takes boolean b returns string
    if (b) then
        return "true"
    endif
    return false
endfunction

That will work.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top