Skip to content

Commit

Permalink
Pattern matching helper for C#
Browse files Browse the repository at this point in the history
  • Loading branch information
mausch committed Jan 10, 2014
1 parent 0981dba commit ec7d7d8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions EdmundsNet/Vehicles.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace EdmundsNet.Vehicles

open System

[<RequireQualifiedAccess>]
type State = New | Used | Future

Expand Down Expand Up @@ -119,6 +121,13 @@ type GeneralEquipment =
| Equipment of Equipment
| Engine of Engine
| Transmission of Transmission
with
member x.Match(equipment: Func<_,_>, engine: Func<_,_>, transmission: Func<_,_>) =
match x with
| Equipment e -> equipment.Invoke e
| Engine e -> engine.Invoke e
| Transmission t -> transmission.Invoke t


type Equipments = {
Equipment: GeneralEquipment list
Expand Down

0 comments on commit ec7d7d8

Please sign in to comment.