When doing this kind of pattern matching it's generally best to add a last catch all case:

match x with

| :? string -> "x is a string"

| :? int -> "x is an int"

| :? Exception -> "x is an exception"

| _ -> Printf.sprintf "x is a %A" (x.GetType())

By on 1/22/2009 1:01 AM ()

Because there are input values for x that aren't matched by any pattern, e.g.

getType System.DateTime.Now

throws a Microsoft.FSharp.Core.MatchFailureException because System.DateTime isn't matched

By on 1/21/2009 11:52 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper