Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
loqi
on Feb 10, 2015
|
parent
|
context
|
favorite
| on:
Swift 1.2 and Xcode 6.3 beta
C++98 (maybe earlier) has a similar feature:
if (mytype* p = find_or_null(blah)) foo(*p);
Still have to dereference p, but at least it's only in scope when doing so is safe. Also goes well with auto and std::optional:
if (auto opt = find_or_none(blah)) foo(*opt);
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: