Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
tomjakubowski
· 10y ago · 0 comments
Not as general or useful as Rust's "if let", though. Rust's "if let" affords fallible pattern matching on arbitrary types, not just on "nullable pointer types" (in Safe Rust, a "nullable pointer" is simply a regular reference wrapped in Option<>).
Comments
[–]
steveklabnik
10y ago
Worth noting that we got the idea for if let from Swift :)
[–]
trevor-e
10y ago
These are the little things I love seeing on HN. :)
[–]
austinz
10y ago
Swift has "if case let" for that use case. (Admittedly, the syntax is a bit esoteric.)
[–]
ahmedk92
10y ago
You can use `as?`:
if let string = thing as? String