lib/dry/monads/list.rb
# Maps a block over the list. Acts as `Array#map`.
# As in other monads if no block given the first argument will
# be treated as callable and used instead.
#
# @example
#   Dry::Monads::List[1, 2].fmap { |x| x + 1 } # => List[2, 3]
#
# @param args [Array<Object>] arguments will be passed to the block or proc
# @return [List]
Maps a block over the list. Acts as `Array#map`.
As in other monads if no block given the first argument will
be treated as callable and used instead.
Maps a block over the list . Acts as ` Array#map ` . As in other monads if no block given the first argument will be treated as callable and used instead .
def fmap(*args)
        if block_given?
          List.new(value.map { |v| yield(v, *args) })
        else
          obj, *rest = args
          List.new(value.map { |v| obj.(v, *rest) })
        end
      end
def fmap ( * args ) if block_given? List . new ( value . map { | v | yield ( v , * args ) } ) else obj , * rest = args List . new ( value . map { | v | obj . ( v , * rest ) } ) end end
Maps a block over the list.
Maps a block over the list .
None
List
args
arguments will be passed to the block or proc
arguments will be passed to the block or proc
example
None