I'd actually like to see a change in guard so that I don't need those
braces. I'd like something more readable like
| guard cond1 or return nil
| guard cond2 or throw MyError.IllegalValue
| guard cond3 or do { ... }
It may add more cases for the compiler to handle but in all cases I
used guard so far the block was never really needed. But I think this
is out of the scope of this thread.
This is a different topic, because it would create an alternative for a
single-expression guard-else-block. ;)
That looks good. You might want to include more complex expressions just to
make it clear that this isn’t limited to literal-returning expressions.
Otherwise I think it covers it. Thanks for putting this together! I’ve wanted
this for a long time… :)
Is this example enough for you, what do you thing?
// Today:
public struct Character {
private let _pointer: UnsafePointer<Swift.Character>
public let source: Module.Source
public var value: Swift.Character {
return self._pointer.memory
}
...
}
// Rewritten:
public struct Character {
...
public var value: Swift.Character { self._pointer.memory }
...
}
--
Adrian Zubarev
Sent with Airmail
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution