You could think of this code as being similiar to this Java code.

1
2
3
4
5
6
7
<T> T getValue(Pair<String,T> a) {
  String s = a.getFst();
  T v = a.getSnd();
  if(s.Equals("lo") || s.Equals("low")) return v;
  else if(s.Equals("hi") || s.Equals("high")) return v;
  else throw new Exception("expected a both a high and low value");
}

Patterns in match blocks can bind new variables. This is how the "v" is declared.

By on 5/8/2008 5:30 AM ()
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