Skip to content

Union matching challenge

October 13, 2011

Occasionally I would capture some interesting features that I came across during my F# exercises. Here is a simple F# snippet:

type TickTack = Tick | Tack

let ticker x =
    match x with
    | Tick -> printfn "Tick"
    | Tock -> printfn "Tock"
    | Tack -> printfn "Tack"

ticker Tick
ticker Tack

The expectation would be that, when being executed it will output

Tick
Tack

However, it outputs

Tick
Tock

instead
Why?

Answer to matching challenge

Advertisements

From → F#

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: