<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 3, 2016 at 11:16 AM Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">You can instead write this way.<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">auto Ret = StringSwitch<Optional<int>>(Str)</div><div class="gmail_msg">    .Case("foo", 1)</div><div class="gmail_msg">    ...</div><div class="gmail_msg">    .Default(None);</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">instead of</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg">auto Ret = StringSwitch<int>(Str)</div><div class="gmail_msg">    .Case("foo", 1)</div><div class="gmail_msg">    ...</div><div class="gmail_msg">    .OrNone();</div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">The former pattern is at least as readable as the latter (to me the former is easier to read), so I don't see a strong reason to add a new method to StringSwitch.</div></div></blockquote><div><br></div><div>Ahh.   I guess the concern I have there is people might not even think to do that.  I guess it's obvious in hindsight but I didn't think of using a different type than the one I wanted as the argument to StringSwitch.  Having an OrNone() method makes it kind of explicit in the interface of the class that this is supported.</div></div></div>