On Monday, October 15, 2012 2:55:49 PM UTC+2, Simon Ochsenreither wrote: > > > One annoyance in Scala is when it infers a type to be, say, List[Nothing], >> which so far has never been what I intended. >> > While I remember some “interesting” type inference results, List[Nothing] > is a bad example. There is only one, single, unique value of List[Nothing] > and it is the empty list. And in fact, that's the only possible element > type of an empty list. > >
That's false; a List[String] can happen to be empty. If you have a scala method which accepts 1 List[String] as argument, you cannot presume that this list will necessarily contain at least 1 element. It is very strange to have an _immutable_ empty List[String] but still perfectly valid: If I need to call a method that takes a List[String], for example for additional arguments to pass to an external process (think j.l.ProcessBuilder), then I probably just want to use a nil list and pass that in, at which point I'll have a List[String] reference that is pointing at an immutable empty list. -- You received this message because you are subscribed to the Google Groups "Java Posse" group. To view this discussion on the web visit https://groups.google.com/d/msg/javaposse/-/TNoc-1FQNQMJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
