Skip to content
Artūras Šlajus edited this page Oct 31, 2016 · 1 revision

These<A, B> is a niche data structure that says A or B or (A and B).

Use cases

Usually it is used when you'd want to pass two options, but (None, None) does not make sense.

var opt1 = returnsOpt1();
var opt2 = returnsOpt2();
var theseOpt = These.a(opt1, opt2);
foreach (var these in theseOpt) doSomething(these);

Usage

  • #thisValue returns Option<A> if left is set.
  • #thatValue returns Option<B> if right is set.
  • #bothValue returns Option<Tpl<A, B>> if both sides are set.

You can also map or flatMap over These.