> On Oct 19, 2016, at 4:50 AM, David Goodine via swift-evolution 
> <swift-evolution@swift.org> wrote:
> 
> Hey all,
> 
> I don’t know if this is really an ‘evolution’ topic per se, and I’m not on 
> Swift Dev, but thought someone here could shed some light on this.
> 
> Often when developing code, if I need create mode switches (constant Bools) 
> so that I can move back and forth between different features/implementations 
> for testing, developing experimental features, migration, etc.  Currently if 
> I write the following:
> 
> let useFoo = true
> 
> if useFoo {
> // Foo code
> } else {
> // Non-Foo code
> }

In your debugging, do you actually need this condition to be evaluated at 
runtime?  For example, in the debugger, are you changing the value of useFoo at 
runtime to switch which branch is used?

If not, maybe #if would be better — it makes the decision at compile time.  I 
don't get any warnings from the following code:

let useFoo = true

#if useFoo
    print("foo code")
#else
    print("non-foo code")
#endif

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to