syntax - Swift Not Equals, Forced Unwrap, and Whitespace -


i've been enjoying swift while now, found 1 syntax incredibly problematic.

start assumption that:

let foo : string = "" 

this simple check:

if foo!="value" { 

but alas, won't compile. compiler complains trying unwrap value not optional. change line to:

if foo != "value { 

the compiler happy , code behaves expected. case of significant whitespace, , i'm not content it. suspect there situations may compile , behave contrary intention. there alternative syntax should using avoid type of error?

the alternate syntax put spaces around infix operators. required. without spaces, treated prefix or postfix operator. spaces infix operator. swift consistent this. know realize what's happening; don't believe there's way around it, , cure worse disease (i can't come examples lead real-world bugs).

swift forgiving if there no conflict, , allow 1+1 instance, shouldn't this, either. believe swift style put spaces in. yes, it's case of significant whitespace. whitespace here significant, can't structfoo when mean struct foo.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -