class_docstr: Class for generating conditional trees based on value of an expression.
  
  Examples
  --------
  
  >>> csq = hl.literal('loss of function')
  >>> expr = (hl.switch(csq)
  ...           .when('synonymous', 1)
  ...           .when('SYN', 1)
  ...           .when('missense', 2)
  ...           .when('MIS', 2)
  ...           .when('loss of function', 3)
  ...           .when('LOF', 3)
  ...           .or_missing())
  >>> hl.eval(expr)
  3
  
  Notes
  -----
  All expressions appearing as the `then` parameters to
  :meth:`~hail.expr.builders.SwitchBuilder.when` or
  :meth:`~hail.expr.builders.SwitchBuilder.default` method calls must be the
  same type.
  
  See Also
  --------
  :func:`.case`, :func:`.cond`, :func:`.switch`
  
  Parameters
  ----------
  expr : :class:`.Expression`
      Value to match against.
class_docstr_tok: ["Class","for","generating","conditional","trees","based","on","value","of","an","expression",".","Examples","--","--","--","--",">",">",">","csq","=","hl.literal","(","'loss","of","function","'",")",">",">",">","expr","=","(","hl.switch","(","csq",")","...",".when","(","'synonymous","'",",","1",")","...",".when","(","'SYN","'",",","1",")","...",".when","(","'missense","'",",","2",")","...",".when","(","'MIS","'",",","2",")","...",".when","(","'loss","of","function","'",",","3",")","...",".when","(","'LOF","'",",","3",")","...",".or_missing","(",")",")",">",">",">","hl.eval","(","expr",")","3","Notes","--","--","-","All","expressions","appearing","as","the","`","then","`","parameters","to",":","meth",":","`","~hail.expr.builders.SwitchBuilder.when","`","or",":","meth",":","`","~hail.expr.builders.SwitchBuilder.default","`","method","calls","must","be","the","same","type",".","See","Also","--","--","--","--",":","func",":","`",".case","`",",",":","func",":","`",".cond","`",",",":","func",":","`",".switch","`","Parameters","--","--","--","--","--","expr",":",":","class",":","`",".Expression","`","Value","to","match","against","."]
docstr: Add a value test. If the `base` expression is equal to `value`, then
  returns `then`.
  
  Warning
  -------
  Missingness always compares to missing. Both ``NA == NA`` and
  ``NA != NA`` return ``NA``. Use :meth:`~SwitchBuilder.when_missing`
  to test missingness.
  
  Parameters
  ----------
  value : :class:`.Expression`
  then : :class:`.Expression`
  
  Returns
  -------
  :class:`.SwitchBuilder`
      Mutates and returns `self`.
docstr_tok: ["Add","a","value","test",".","If","the","`","base","`","expression","is","equal","to","`","value","`",",","then","returns","`","then","`",".","Warning","--","--","--","-","Missingness","always","compares","to","missing",".","Both","``","NA","==","NA","``","and","``","NA","!","=","NA","``","return","``","NA","``",".","Use",":","meth",":","`","~SwitchBuilder.when_missing","`","to","test","missingness",".","Parameters","--","--","--","--","--","value",":",":","class",":","`",".Expression","`","then",":",":","class",":","`",".Expression","`","Returns","--","--","--","-",":","class",":","`",".SwitchBuilder","`","Mutates","and","returns","`","self","`","."]
code: def when(self, value, then) -> "SwitchBuilder":
      """Add a value test. If the `base` expression is equal to `value`, then
      returns `then`.
  
      Warning
      -------
      Missingness always compares to missing. Both ``NA == NA`` and
      ``NA != NA`` return ``NA``. Use :meth:`~SwitchBuilder.when_missing`
      to test missingness.
  
      Parameters
      ----------
      value : :class:`.Expression`
      then : :class:`.Expression`
  
      Returns
      -------
      :class:`.SwitchBuilder`
          Mutates and returns `self`.
      """
      can_compare = unify_types(self._base.dtype, value.dtype)
      if not can_compare:
          raise TypeError(
              "cannot compare expressions of type '{}' and '{}'".format(
                  self._base.dtype, value.dtype
              )
          )
  
      self._unify_type(then.dtype)
      self._cases.append((value, then))
      return self
  
imports: import hail
  from hail.typecheck import typecheck_method
  from hail.expr.expressions import unify_types, unify_types_limited, expr_any, expr_bool, ExpressionException, construct_expr, expr_str
  from hail import ir
label_desc: Use image node_id 3 for calling the SwitchBuilder obj's underlying member method code with example usage: obj.when(value, then) and returns: self