Add unless/if single line syntax


(James Campbell) #1

I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and pyramids of doom

···

Sent from my iPhone


(Chéyo Jiménez) #2

-1 from me. I think I would rather have an if-then expression that would
handle both False and True cases.
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001944.html

Also, in most cases I feel that guard would be a better choice.

···

On Sat, Dec 12, 2015 at 5:39 AM, James Campbell via swift-evolution < swift-evolution@swift.org> wrote:

I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and
pyramids of doom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Arthur Ariel Sabintsev) #3

For your specific example, I'd 100% use the guard statement. It achieves
the same result.

-1 from me.

···

On Sat, Dec 12, 2015 at 9:43 AM J. Cheyo Jimenez via swift-evolution < swift-evolution@swift.org> wrote:

-1 from me. I think I would rather have an if-then expression that would
handle both False and True cases.

https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001944.html

Also, in most cases I feel that guard would be a better choice.

On Sat, Dec 12, 2015 at 5:39 AM, James Campbell via swift-evolution < > swift-evolution@swift.org> wrote:

I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and
pyramids of doom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

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


(Matthew Johnson) #4

I’m not sure about the single line aspect of this proposal, but I am a big proponent of “unless” and “until” as complements to “if” and “while”. They greatly improve readability over "if !(expression)” and “while !(expression)” IMHO.

···

On Dec 12, 2015, at 9:45 AM, Arthur Ariel Sabintsev via swift-evolution <swift-evolution@swift.org> wrote:

For your specific example, I'd 100% use the guard statement. It achieves the same result.

-1 from me.
On Sat, Dec 12, 2015 at 9:43 AM J. Cheyo Jimenez via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
-1 from me. I think I would rather have an if-then expression that would handle both False and True cases.
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001944.html

Also, in most cases I feel that guard would be a better choice.

On Sat, Dec 12, 2015 at 5:39 AM, James Campbell via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and pyramids of doom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

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


(Al Skipp) #5

If at all possible I think it’s best to avoid adding keywords to the language. Instead of ‘unless', you could do:

public func not(bool: Bool) -> Bool { return !bool }

if not(condition) { print("condition was false") }

Not terrible ¯\_(ツ)_/¯

···

On 12 Dec 2015, at 15:48, Matthew Johnson via swift-evolution <swift-evolution@swift.org> wrote:

I’m not sure about the single line aspect of this proposal, but I am a big proponent of “unless” and “until” as complements to “if” and “while”. They greatly improve readability over "if !(expression)” and “while !(expression)” IMHO.

On Dec 12, 2015, at 9:45 AM, Arthur Ariel Sabintsev via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

For your specific example, I'd 100% use the guard statement. It achieves the same result.

-1 from me.
On Sat, Dec 12, 2015 at 9:43 AM J. Cheyo Jimenez via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
-1 from me. I think I would rather have an if-then expression that would handle both False and True cases.
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001944.html

Also, in most cases I feel that guard would be a better choice.

On Sat, Dec 12, 2015 at 5:39 AM, James Campbell via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and pyramids of doom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

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

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


(Matthew Johnson) #6

I’ve written enough Ruby code to appreciate these keywords and believe they are worth adding the keywords. I know others don’t agree and that the Swift team considered this earlier and did not add them for the exact reason you stated.

I think it would be good to get a read on where the community stands. I’m not sure which opinion is in the majority.

···

On Dec 12, 2015, at 10:08 AM, Al Skipp <al_skipp@fastmail.fm> wrote:

If at all possible I think it’s best to avoid adding keywords to the language. Instead of ‘unless', you could do:

public func not(bool: Bool) -> Bool { return !bool }

if not(condition) { print("condition was false") }

Not terrible ¯\_(ツ)_/¯

On 12 Dec 2015, at 15:48, Matthew Johnson via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

I’m not sure about the single line aspect of this proposal, but I am a big proponent of “unless” and “until” as complements to “if” and “while”. They greatly improve readability over "if !(expression)” and “while !(expression)” IMHO.

On Dec 12, 2015, at 9:45 AM, Arthur Ariel Sabintsev via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

For your specific example, I'd 100% use the guard statement. It achieves the same result.

-1 from me.
On Sat, Dec 12, 2015 at 9:43 AM J. Cheyo Jimenez via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
-1 from me. I think I would rather have an if-then expression that would handle both False and True cases.
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001944.html

Also, in most cases I feel that guard would be a better choice.

On Sat, Dec 12, 2015 at 5:39 AM, James Campbell via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and pyramids of doom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

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

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


(James Campbell) #7

For what it's worth. If swift is about clarity, then guard is quite an
obscure keyword.

···

On Sat, Dec 12, 2015 at 4:12 PM, Matthew Johnson via swift-evolution < swift-evolution@swift.org> wrote:

I’ve written enough Ruby code to appreciate these keywords and believe
they are worth adding the keywords. I know others don’t agree and that the
Swift team considered this earlier and did not add them for the exact
reason you stated.

I think it would be good to get a read on where the community stands. I’m
not sure which opinion is in the majority.

On Dec 12, 2015, at 10:08 AM, Al Skipp <al_skipp@fastmail.fm> wrote:

If at all possible I think it’s best to avoid adding keywords to the
language. Instead of ‘unless', you could do:

public func not(bool: Bool) -> Bool { return !bool }

if not(condition) { print("condition was false") }

Not terrible ¯\_(ツ)_/¯

On 12 Dec 2015, at 15:48, Matthew Johnson via swift-evolution < > swift-evolution@swift.org> wrote:

I’m not sure about the single line aspect of this proposal, but I am a big
proponent of “unless” and “until” as complements to “if” and “while”. They
greatly improve readability over "if !(expression)” and “while
!(expression)” IMHO.

On Dec 12, 2015, at 9:45 AM, Arthur Ariel Sabintsev via swift-evolution < > swift-evolution@swift.org> wrote:

For your specific example, I'd 100% use the guard statement. It achieves
the same result.

-1 from me.
On Sat, Dec 12, 2015 at 9:43 AM J. Cheyo Jimenez via swift-evolution < > swift-evolution@swift.org> wrote:

-1 from me. I think I would rather have an if-then expression that would
handle both False and True cases.

https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001944.html

Also, in most cases I feel that guard would be a better choice.

On Sat, Dec 12, 2015 at 5:39 AM, James Campbell via swift-evolution < >> swift-evolution@swift.org> wrote:

I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and
pyramids of doom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

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

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

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

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

--
 Wizard
james@supmenow.com
+44 7523 279 698


(Tommy van der Vorst) #8

Or, use something like this:

public func unless(expression: @autoclosure () -> Bool, block: () -> ()) {
  if !expression {
    block()
  }
}

unless(..expression..) {
  ...code...
}

/T

···

Op 12 dec. 2015, om 17:08 heeft Al Skipp via swift-evolution <swift-evolution@swift.org> het volgende geschreven:

If at all possible I think it’s best to avoid adding keywords to the language. Instead of ‘unless', you could do:

public func not(bool: Bool) -> Bool { return !bool }

if not(condition) { print("condition was false") }

Not terrible ¯\_(ツ)_/¯

On 12 Dec 2015, at 15:48, Matthew Johnson via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

I’m not sure about the single line aspect of this proposal, but I am a big proponent of “unless” and “until” as complements to “if” and “while”. They greatly improve readability over "if !(expression)” and “while !(expression)” IMHO.

On Dec 12, 2015, at 9:45 AM, Arthur Ariel Sabintsev via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

For your specific example, I'd 100% use the guard statement. It achieves the same result.

-1 from me.
On Sat, Dec 12, 2015 at 9:43 AM J. Cheyo Jimenez via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
-1 from me. I think I would rather have an if-then expression that would handle both False and True cases.
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001944.html

Also, in most cases I feel that guard would be a better choice.

On Sat, Dec 12, 2015 at 5:39 AM, James Campbell via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and pyramids of doom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

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

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

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


(Tommy van der Vorst) #9

Oops, that should be just:

public func unless(expression: Bool, block: () -> ()) {
  if !expression {
    block()
  }
}

···

Op 12 dec. 2015, om 17:17 heeft Tommy van der Vorst via swift-evolution <swift-evolution@swift.org> het volgende geschreven:

Or, use something like this:

public func unless(expression: @autoclosure () -> Bool, block: () -> ()) {
  if !expression {
    block()
  }
}

unless(..expression..) {
  ...code...
}

/T

Op 12 dec. 2015, om 17:08 heeft Al Skipp via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> het volgende geschreven:

If at all possible I think it’s best to avoid adding keywords to the language. Instead of ‘unless', you could do:

public func not(bool: Bool) -> Bool { return !bool }

if not(condition) { print("condition was false") }

Not terrible ¯\_(ツ)_/¯

On 12 Dec 2015, at 15:48, Matthew Johnson via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

I’m not sure about the single line aspect of this proposal, but I am a big proponent of “unless” and “until” as complements to “if” and “while”. They greatly improve readability over "if !(expression)” and “while !(expression)” IMHO.

On Dec 12, 2015, at 9:45 AM, Arthur Ariel Sabintsev via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

For your specific example, I'd 100% use the guard statement. It achieves the same result.

-1 from me.
On Sat, Dec 12, 2015 at 9:43 AM J. Cheyo Jimenez via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
-1 from me. I think I would rather have an if-then expression that would handle both False and True cases.
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001944.html

Also, in most cases I feel that guard would be a better choice.

On Sat, Dec 12, 2015 at 5:39 AM, James Campbell via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and pyramids of doom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

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

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

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

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


(Matthew Johnson) #10

The feature implemented in the language. What’s not to like?

Closures don't support non-local control (i.e. returning from the function that calls this unless function).

If Joe Groff's idea on adding non-local control were adopted that would solve this problem and defining it as a function like this might be acceptable.

I don't think until is solved as easily but it's utility is also more rare.

That said, I'm not sure there is a good argument against "unless" and "until" being keywords. The argument seems to be a general desire to keep keyword usage to a minimum. I agree with that in general but I also think it's good to consider potential reasons a programmer would want to use specific words as an identifier.

IMO the meaning of these words is specific enough that the value of making them part of the language probably outweighs their utility as identifiers when the language itself implements the obvious meaning.

If we don't see them added to the language I think it would be good to add the functions to the standard library so they are a part of the common vocabulary for all Swift developers. Of course this is just my humble opinion.

Matthew


(Amir Michail) #11

Top marks!

unless(condition) { print("condition was false") }

Implicitly negated conditions cause confusion and bugs.

···

On Dec 12, 2015, at 11:28 AM, Al Skipp via swift-evolution <swift-evolution@swift.org> wrote:

The feature implemented in the language. What’s not to like?

On 12 Dec 2015, at 16:20, Tommy van der Vorst via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

Oops, that should be just:

public func unless(expression: Bool, block: () -> ()) {
  if !expression {
    block()
  }
}

Op 12 dec. 2015, om 17:17 heeft Tommy van der Vorst via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> het volgende geschreven:

Or, use something like this:

public func unless(expression: @autoclosure () -> Bool, block: () -> ()) {
  if !expression {
    block()
  }
}

unless(..expression..) {
  ...code...
}

/T

Op 12 dec. 2015, om 17:08 heeft Al Skipp via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> het volgende geschreven:

If at all possible I think it’s best to avoid adding keywords to the language. Instead of ‘unless', you could do:

public func not(bool: Bool) -> Bool { return !bool }

if not(condition) { print("condition was false") }

Not terrible ¯\_(ツ)_/¯

On 12 Dec 2015, at 15:48, Matthew Johnson via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

I’m not sure about the single line aspect of this proposal, but I am a big proponent of “unless” and “until” as complements to “if” and “while”. They greatly improve readability over "if !(expression)” and “while !(expression)” IMHO.

On Dec 12, 2015, at 9:45 AM, Arthur Ariel Sabintsev via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

For your specific example, I'd 100% use the guard statement. It achieves the same result.

-1 from me.
On Sat, Dec 12, 2015 at 9:43 AM J. Cheyo Jimenez via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
-1 from me. I think I would rather have an if-then expression that would handle both False and True cases.
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001944.html

Also, in most cases I feel that guard would be a better choice.

On Sat, Dec 12, 2015 at 5:39 AM, James Campbell via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and pyramids of doom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

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

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

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

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

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

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


(Al Skipp) #12

Top marks!

unless(condition) { print("condition was false") }

The feature implemented in the language. What’s not to like?

···

On 12 Dec 2015, at 16:20, Tommy van der Vorst via swift-evolution <swift-evolution@swift.org> wrote:

Oops, that should be just:

public func unless(expression: Bool, block: () -> ()) {
  if !expression {
    block()
  }
}

Op 12 dec. 2015, om 17:17 heeft Tommy van der Vorst via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> het volgende geschreven:

Or, use something like this:

public func unless(expression: @autoclosure () -> Bool, block: () -> ()) {
  if !expression {
    block()
  }
}

unless(..expression..) {
  ...code...
}

/T

Op 12 dec. 2015, om 17:08 heeft Al Skipp via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> het volgende geschreven:

If at all possible I think it’s best to avoid adding keywords to the language. Instead of ‘unless', you could do:

public func not(bool: Bool) -> Bool { return !bool }

if not(condition) { print("condition was false") }

Not terrible ¯\_(ツ)_/¯

On 12 Dec 2015, at 15:48, Matthew Johnson via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

I’m not sure about the single line aspect of this proposal, but I am a big proponent of “unless” and “until” as complements to “if” and “while”. They greatly improve readability over "if !(expression)” and “while !(expression)” IMHO.

On Dec 12, 2015, at 9:45 AM, Arthur Ariel Sabintsev via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

For your specific example, I'd 100% use the guard statement. It achieves the same result.

-1 from me.
On Sat, Dec 12, 2015 at 9:43 AM J. Cheyo Jimenez via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
-1 from me. I think I would rather have an if-then expression that would handle both False and True cases.
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001944.html

Also, in most cases I feel that guard would be a better choice.

On Sat, Dec 12, 2015 at 5:39 AM, James Campbell via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and pyramids of doom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

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

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

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

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

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


(James Campbell) #13

So

guard username.text.characters.count > 0 else {
        return
    }

could be expressed as

unless(username.text.characters.count > 0) {
        return
    }

I think the second is much easier to read :slight_smile:

···

On Sat, Dec 12, 2015 at 4:28 PM, Al Skipp via swift-evolution < swift-evolution@swift.org> wrote:

Top marks!

unless(condition) { print("condition was false") }

The feature implemented in the language. What’s not to like?

On 12 Dec 2015, at 16:20, Tommy van der Vorst via swift-evolution < > swift-evolution@swift.org> wrote:

Oops, that should be just:

public func unless(expression: Bool, block: () -> ()) {
if !expression {
block()
}
}

Op 12 dec. 2015, om 17:17 heeft Tommy van der Vorst via swift-evolution < > swift-evolution@swift.org> het volgende geschreven:

Or, use something like this:

public func unless(expression: @autoclosure () -> Bool, block: () -> ()) {
if !expression {
block()
}
}

unless(..expression..) {
...code...
}

/T

Op 12 dec. 2015, om 17:08 heeft Al Skipp via swift-evolution < > swift-evolution@swift.org> het volgende geschreven:

If at all possible I think it’s best to avoid adding keywords to the
language. Instead of ‘unless', you could do:

public func not(bool: Bool) -> Bool { return !bool }

if not(condition) { print("condition was false") }

Not terrible ¯\_(ツ)_/¯

On 12 Dec 2015, at 15:48, Matthew Johnson via swift-evolution < > swift-evolution@swift.org> wrote:

I’m not sure about the single line aspect of this proposal, but I am a big
proponent of “unless” and “until” as complements to “if” and “while”. They
greatly improve readability over "if !(expression)” and “while
!(expression)” IMHO.

On Dec 12, 2015, at 9:45 AM, Arthur Ariel Sabintsev via swift-evolution < > swift-evolution@swift.org> wrote:

For your specific example, I'd 100% use the guard statement. It achieves
the same result.

-1 from me.
On Sat, Dec 12, 2015 at 9:43 AM J. Cheyo Jimenez via swift-evolution < > swift-evolution@swift.org> wrote:

-1 from me. I think I would rather have an if-then expression that would
handle both False and True cases.

https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001944.html

Also, in most cases I feel that guard would be a better choice.

On Sat, Dec 12, 2015 at 5:39 AM, James Campbell via swift-evolution < >> swift-evolution@swift.org> wrote:

I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and
pyramids of doom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

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

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

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

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

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

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

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

--
 Wizard
james@supmenow.com
+44 7523 279 698


(Jason Dusek) #14

Say <expr: T> if <expr: Bool> had type T -- it would dovetail naturally
with optional chaining.

Best Regards,

Jason


(Etan Kissling) #15

It's not the same, OP wants to return nil.

So you have to write

return unless(username.text.characters.count > 0) {
    return
}

and if you miss the first return, you just introduced a bug.

Etan

···

On 12 Dec 2015, at 18:17, James Campbell via swift-evolution <swift-evolution@swift.org> wrote:

So

guard username.text.characters.count > 0 else {
        return
    }
could be expressed as
unless(username.text.characters.count > 0) {
        return
    }
I think the second is much easier to read :slight_smile:

On Sat, Dec 12, 2015 at 4:28 PM, Al Skipp via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
Top marks!

unless(condition) { print("condition was false") }

The feature implemented in the language. What’s not to like?

On 12 Dec 2015, at 16:20, Tommy van der Vorst via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

Oops, that should be just:

public func unless(expression: Bool, block: () -> ()) {
  if !expression {
    block()
  }
}

Op 12 dec. 2015, om 17:17 heeft Tommy van der Vorst via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> het volgende geschreven:

Or, use something like this:

public func unless(expression: @autoclosure () -> Bool, block: () -> ()) {
  if !expression {
    block()
  }
}

unless(..expression..) {
  ...code...
}

/T

Op 12 dec. 2015, om 17:08 heeft Al Skipp via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> het volgende geschreven:

If at all possible I think it’s best to avoid adding keywords to the language. Instead of ‘unless', you could do:

public func not(bool: Bool) -> Bool { return !bool }

if not(condition) { print("condition was false") }

Not terrible ¯\_(ツ)_/¯

On 12 Dec 2015, at 15:48, Matthew Johnson via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

I’m not sure about the single line aspect of this proposal, but I am a big proponent of “unless” and “until” as complements to “if” and “while”. They greatly improve readability over "if !(expression)” and “while !(expression)” IMHO.

On Dec 12, 2015, at 9:45 AM, Arthur Ariel Sabintsev via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

For your specific example, I'd 100% use the guard statement. It achieves the same result.

-1 from me.
On Sat, Dec 12, 2015 at 9:43 AM J. Cheyo Jimenez via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
-1 from me. I think I would rather have an if-then expression that would handle both False and True cases.
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001944.html

Also, in most cases I feel that guard would be a better choice.

On Sat, Dec 12, 2015 at 5:39 AM, James Campbell via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and pyramids of doom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

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

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

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

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

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

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

--
 Wizard
james@supmenow.com <mailto:james@supmenow.com>
+44 7523 279 698
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution


(Etan Kissling) #16

Sorry,

return unless(username.text.characters.count > 0) {
    return nil
}

···

On 14 Dec 2015, at 12:53, Etan Kissling <kissling@oberon.ch> wrote:

It's not the same, OP wants to return nil.

So you have to write

return unless(username.text.characters.count > 0) {
    return
}

and if you miss the first return, you just introduced a bug.

Etan

On 12 Dec 2015, at 18:17, James Campbell via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

So

guard username.text.characters.count > 0 else {
        return
    }
could be expressed as
unless(username.text.characters.count > 0) {
        return
    }
I think the second is much easier to read :slight_smile:

On Sat, Dec 12, 2015 at 4:28 PM, Al Skipp via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
Top marks!

unless(condition) { print("condition was false") }

The feature implemented in the language. What’s not to like?

On 12 Dec 2015, at 16:20, Tommy van der Vorst via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

Oops, that should be just:

public func unless(expression: Bool, block: () -> ()) {
  if !expression {
    block()
  }
}

Op 12 dec. 2015, om 17:17 heeft Tommy van der Vorst via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> het volgende geschreven:

Or, use something like this:

public func unless(expression: @autoclosure () -> Bool, block: () -> ()) {
  if !expression {
    block()
  }
}

unless(..expression..) {
  ...code...
}

/T

Op 12 dec. 2015, om 17:08 heeft Al Skipp via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> het volgende geschreven:

If at all possible I think it’s best to avoid adding keywords to the language. Instead of ‘unless', you could do:

public func not(bool: Bool) -> Bool { return !bool }

if not(condition) { print("condition was false") }

Not terrible ¯\_(ツ)_/¯

On 12 Dec 2015, at 15:48, Matthew Johnson via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

I’m not sure about the single line aspect of this proposal, but I am a big proponent of “unless” and “until” as complements to “if” and “while”. They greatly improve readability over "if !(expression)” and “while !(expression)” IMHO.

On Dec 12, 2015, at 9:45 AM, Arthur Ariel Sabintsev via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

For your specific example, I'd 100% use the guard statement. It achieves the same result.

-1 from me.
On Sat, Dec 12, 2015 at 9:43 AM J. Cheyo Jimenez via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
-1 from me. I think I would rather have an if-then expression that would handle both False and True cases.
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001944.html

Also, in most cases I feel that guard would be a better choice.

On Sat, Dec 12, 2015 at 5:39 AM, James Campbell via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and pyramids of doom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

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

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

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

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

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

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

--
 Wizard
james@supmenow.com <mailto:james@supmenow.com>
+44 7523 279 698
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution


(Tommy van der Vorst) #17

encrypted.asc (8.43 KB)


(Tommy van der Vorst) #18

Well that can be easily mitigated by adding an @warn_unused_result...

/T

···

Op 14 dec. 2015, om 12:53 heeft Etan Kissling <kissling@oberon.ch <mailto:kissling@oberon.ch>> het volgende geschreven:

It's not the same, OP wants to return nil.

So you have to write

return unless(username.text.characters.count > 0) {
    return
}

and if you miss the first return, you just introduced a bug.

Etan

On 12 Dec 2015, at 18:17, James Campbell via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

So

guard username.text.characters.count > 0 else {
        return
    }
could be expressed as
unless(username.text.characters.count > 0) {
        return
    }
I think the second is much easier to read :slight_smile:

On Sat, Dec 12, 2015 at 4:28 PM, Al Skipp via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
Top marks!

unless(condition) { print("condition was false") }

The feature implemented in the language. What’s not to like?

On 12 Dec 2015, at 16:20, Tommy van der Vorst via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

Oops, that should be just:

public func unless(expression: Bool, block: () -> ()) {
  if !expression {
    block()
  }
}

Op 12 dec. 2015, om 17:17 heeft Tommy van der Vorst via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> het volgende geschreven:

Or, use something like this:

public func unless(expression: @autoclosure () -> Bool, block: () -> ()) {
  if !expression {
    block()
  }
}

unless(..expression..) {
  ...code...
}

/T

Op 12 dec. 2015, om 17:08 heeft Al Skipp via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> het volgende geschreven:

If at all possible I think it’s best to avoid adding keywords to the language. Instead of ‘unless', you could do:

public func not(bool: Bool) -> Bool { return !bool }

if not(condition) { print("condition was false") }

Not terrible ¯\_(ツ)_/¯

On 12 Dec 2015, at 15:48, Matthew Johnson via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

I’m not sure about the single line aspect of this proposal, but I am a big proponent of “unless” and “until” as complements to “if” and “while”. They greatly improve readability over "if !(expression)” and “while !(expression)” IMHO.

On Dec 12, 2015, at 9:45 AM, Arthur Ariel Sabintsev via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

For your specific example, I'd 100% use the guard statement. It achieves the same result.

-1 from me.
On Sat, Dec 12, 2015 at 9:43 AM J. Cheyo Jimenez via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
-1 from me. I think I would rather have an if-then expression that would handle both False and True cases.
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001944.html

Also, in most cases I feel that guard would be a better choice.

On Sat, Dec 12, 2015 at 5:39 AM, James Campbell via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and pyramids of doom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

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

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

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

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

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

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

--
 Wizard
james@supmenow.com <mailto:james@supmenow.com>
+44 7523 279 698
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution


(Tommy van der Vorst) #19

(James Campbell) #20

If you implemented it the same way. For me if we just had a unless which was the opposite an if it would be a better syntax than guard.

···

Sent from my iPhone

On 14 Dec 2015, at 11:53, Etan Kissling <kissling@oberon.ch> wrote:

Sorry,

return unless(username.text.characters.count > 0) {
    return nil
}

On 14 Dec 2015, at 12:53, Etan Kissling <kissling@oberon.ch> wrote:

It's not the same, OP wants to return nil.

So you have to write

return unless(username.text.characters.count > 0) {
    return
}

and if you miss the first return, you just introduced a bug.

Etan

On 12 Dec 2015, at 18:17, James Campbell via swift-evolution <swift-evolution@swift.org> wrote:

So

guard username.text.characters.count > 0 else {
        return
    }
could be expressed as
unless(username.text.characters.count > 0) {
        return
    }
I think the second is much easier to read :slight_smile:

On Sat, Dec 12, 2015 at 4:28 PM, Al Skipp via swift-evolution <swift-evolution@swift.org> wrote:
Top marks!

unless(condition) { print("condition was false") }

The feature implemented in the language. What’s not to like?

On 12 Dec 2015, at 16:20, Tommy van der Vorst via swift-evolution <swift-evolution@swift.org> wrote:

Oops, that should be just:

public func unless(expression: Bool, block: () -> ()) {
  if !expression {
    block()
  }
}

Op 12 dec. 2015, om 17:17 heeft Tommy van der Vorst via swift-evolution <swift-evolution@swift.org> het volgende geschreven:

Or, use something like this:

public func unless(expression: @autoclosure () -> Bool, block: () -> ()) {
  if !expression {
    block()
  }
}

unless(..expression..) {
  ...code...
}

/T

Op 12 dec. 2015, om 17:08 heeft Al Skipp via swift-evolution <swift-evolution@swift.org> het volgende geschreven:

If at all possible I think it’s best to avoid adding keywords to the language. Instead of ‘unless', you could do:

public func not(bool: Bool) -> Bool { return !bool }

if not(condition) { print("condition was false") }

Not terrible ¯\_(ツ)_/¯

On 12 Dec 2015, at 15:48, Matthew Johnson via swift-evolution <swift-evolution@swift.org> wrote:

I’m not sure about the single line aspect of this proposal, but I am a big proponent of “unless” and “until” as complements to “if” and “while”. They greatly improve readability over "if !(expression)” and “while !(expression)” IMHO.

On Dec 12, 2015, at 9:45 AM, Arthur Ariel Sabintsev via swift-evolution <swift-evolution@swift.org> wrote:

For your specific example, I'd 100% use the guard statement. It achieves the same result.

-1 from me.

On Sat, Dec 12, 2015 at 9:43 AM J. Cheyo Jimenez via swift-evolution <swift-evolution@swift.org> wrote:
-1 from me. I think I would rather have an if-then expression that would handle both False and True cases.
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001944.html

Also, in most cases I feel that guard would be a better choice.

On Sat, Dec 12, 2015 at 5:39 AM, James Campbell via swift-evolution <swift-evolution@swift.org> wrote:
I propose adding the unless and if statements from ruby.

Return false if james = nil

This returns false if the variable James is nil
. This line does it unless james is nil:

Return false unless james = nil

This has been really handy when working in ruby, reduces lines and pyramids of doom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

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

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

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

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

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

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

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

--
 Wizard
james@supmenow.com
+44 7523 279 698
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution