> I think this would be the standard syntax:
>
> if let value = key.map({ dict[$0] }) {
>
> }
In this case, I think you actually want a flatMap, to merge the two `nil` cases
instead of nesting them.
if let value = key.flatMap({ dict[$0] }) {
}
I wish that
if let value = map(key) { dict($0) }
Félix
> Le 22 déc. 2015 à 13:00:45, Erica Sadun via swift-evolution
> a écrit :
>
> if let key = key, value = dict[key] {
>...whatever...
> }
>
> seems to work fine without introducing a new construct
>
> -- E, waving hi to
I think this would be the standard syntax:
if let value = key.map({ dict[$0] }) {
}
> On Dec 22, 2015, at 10:33 AM, Félix Cloutier via swift-evolution
> wrote:
>
> if let value = map(key) { dict($0) }
>
> Félix
>
>> Le 22 déc. 2015 à 13:00:45, Erica Sadun via
if let key = key, value = dict[key] {
...whatever...
}
seems to work fine without introducing a new construct
-- E, waving hi to John
> On Dec 22, 2015, at 4:37 AM, John Holdsworth via swift-evolution
> wrote:
>
> This isn’t the most compelling of ideas but a
This isn’t the most compelling of ideas but a couple of times I’ve found myself
writing:
if let value = key != nil ? dict[key] : nil {…
and was wondering if the syntax could be:
if let value = dict[key?] {…
The key for dictionaries could be made optional in stdlib but this is probably
best