Class: Either::Right

Inherits:
Object
  • Object
show all
Includes:
Shared
Defined in:
lib/either.rb

Instance Method Summary collapse

Methods included from Shared

#==, #val_eq?

Constructor Details

#initialize(val) ⇒ Right

Returns a new instance of Right.



61
62
63
# File 'lib/either.rb', line 61

def initialize(val)
  @val = val
end

Instance Method Details

#flat_map {|val| ... } ⇒ Object

Yields:

  • (val)


69
70
71
# File 'lib/either.rb', line 69

def flat_map
  yield val
end

#left?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/either.rb', line 54

def left?
  false
end

#mapObject



65
66
67
# File 'lib/either.rb', line 65

def map
  Either.new { yield val }
end

#right?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/either.rb', line 57

def right?
  true
end