Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate optional property comparison operators. #42

Open
kjessup opened this issue May 20, 2018 · 0 comments
Open

Investigate optional property comparison operators. #42

kjessup opened this issue May 20, 2018 · 0 comments

Comments

@kjessup
Copy link
Member

kjessup commented May 20, 2018

struct Foo {
let d: Double?
}

…where(\Foo.d < 5.0)…

The above gives a compilation error.
Work around is:

…where(\Foo.d! < 5.0)…

While Swift won't technically let you do a comparison with an unwrapped optional:

var d: Double? = 4.0
d < 5.0
error: repl.swift:5:3: error: binary operator '<' cannot be applied to operands of type 'Double?' and 'Double'
d < 5.0
~ ^ ~~~

it's ok in SQL.
Look into making this work without the "force unwrap" of the property. (It's not actually force unwrapping.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant