News for hackers. Stuff that matters.
Re:Everything about Java 8 by gjulianm on Wednesday March 27, 2013 @01:58PM (#5450959)
Well, you could substitute that for

     if(Int.CanParse(s))
     {
         i = Int.Parse(s);
         // OK things.
     }
     else
     {
        // Not ok.
     }
but it also be weird in Java because Parse throws and exception, so you'd have to either write an empty catch block or declare the method with a throw clause, event though it actually doesn't throw anything.
Re:Everything about Java 8 by Someone on Wednesday March 27, 2013 @02:34PM (#5451167)
That either is inefficient (you end up parsing each number twice) or requires the compiler to have deep knowledge of the standard library.

Similarly, C# has TryGet where in Java, you need a containsKey/get combo, or have to assume your collections do not store nulls.

I do think C# could do better, though. Neither C# nor Java have the equivalent of "insert ... on duplicate key ..." for collections. You now have to do:

   items.TryGet( key, out value);
   items[key] = value + 1;
In C++, that would just be:

   items[key] += 1;
Re:Everything about Java 8 by mercurial on Wednesday March 27, 2013 @03:27PM (#5451474)
You could have a method returning a nullable Integer.