match tuple with null

I don't understand why the following case doesn't match. Null should be an instance of Any, but it doesn't match. Can someone explain what is going on?

val x = (2, null)
x match {
    case (i:Int, v:Any) => println("got tuple %s: %s".format(i, v))
    case _ => println("catch all")

prints catch all



This is exactly as specified.

Type patterns consist of types, type variables, and wildcards.
A type pattern T is of one of the following forms:

* A reference to a class C, p.C, or T#C.
This type pattern matches any non-null instance of the given class.

It's interesting that so much relevance has been attributed to null being a member of Any. It's a member of every type but AnyVal and Nothing.

Need Your Help

Needed help to access XML data present on a different domain

javascript xml json xmlhttprequest

I have a webservice present on a different domain(basically an authentication servlet) and it returns data in XML format, so whenever I try to make an XMLHttpRequest object and call this service I ...

Mobile phones supporting Java Android?

java android nokia

What are mobile phones supporting Java Android?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.