Comment

Comment by WmyEE0UsWAwC2i

I don't think that's the best way to use Optional in java. In particular the use of isPresent & get kind of defeats the purpose. Should be something along the lines :

   ...
   sum = 0
   opt = getOptional(n)
   sum = sum + opt.orElse(0);
   ...
Also maybe use something like OptionalInt (but for long).

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton