Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
LP0 ON FIRE
Jan 25, 2006

beep boop

Quoted from The Swift Programming Language iBook

Does this mean you can't simply see if a boolean is true by doing something like if(trueBool){...} and requires to put YES or TRUE like if(trueBool==YES){...} ?

Adbot
ADBOT LOVES YOU

LP0 ON FIRE
Jan 25, 2006

beep boop

rjmccall posted:


I'll mention custom operators in :siren: my talk :siren:, and I'm pretty sure they're covered in the guide, but essentially you just declare the operator somewhere in the program:

Swift code:
operator infix|postfix|prefix %%% {
  // You can skip these and Swift will just complain if you ever write this next to another binary operator.
  // associativity left|right
  // precedence some-magic-number
}
And then you define a global function with that name:

Swift code:
func %%%(a: Int, b: Int) -> (Int,Bool) {
  // whatever
}
(Advanced Swift, Thursday at 11:30)

I was just reading about this. If I'm understanding correctly, it can be any sequence of the following 14 characters: / = - + * % < > ! & | ^ . ~
https://developer.apple.com/library...097-CH27-XID_48

LP0 ON FIRE
Jan 25, 2006

beep boop

rjmccall posted:

. is restricted. You can also use non-ASCII characters; we haven't decide exactly which set, but it'll include the math symbols for sure.

Awesome! Someone in another thread about Swift wanted to use ∈ really badly.

  • Locked thread