Y
Hacker News
new
|
ask
|
show
|
jobs
by
ucho
3536 days ago
Java has also alternative approach:
final a; if (predicate) { a = 3; } else { a = 5; }
`final` makes it possible for variable to be assigned exactly once. Verbose but useful when "?:" is not a good fit.