Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It could be allowed. Consider the case of var-args method called with a null value. Say you call the method ambiguousNull(String ...args) like so:

    ambiguousNull(null);
Should args be null? Or should args be new String[]{null}? In the absence of any more information the compiler chooses the first, but may still issue a warning. But you can clearly disambiguate by casting:

    ambiguousNull((String)null); // args is null
    ambiguousNull((String[])null); // args is a 1-element array


So given

  int something() { }
  String something() { }
A hypothetical calling syntax could be

  (int)something();
Or the compiler could even choose one for you with a warning. Seems like a good suggestion for Java 10.


It seems like a in the case of var args, the args should always be an array, since the meat of most var args based functions is iterating over that array.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: