MCPcopy
hub / github.com/dry-python/returns / map

Method map

returns/io.py:80–100  ·  view source on GitHub ↗

Applies function to the inner value. Applies 'function' to the contents of the IO instance and returns a new IO object containing the result. 'function' should accept a single "normal" (non-container) argument and return a non-container result. .. c

(
        self,
        function: Callable[[_ValueType_co], _NewValueType],
    )

Source from the content-addressed store, hash-verified

78 super().__init__(inner_value)
79
80 def map(
81 self,
82 function: Callable[[_ValueType_co], _NewValueType],
83 ) -> 'IO[_NewValueType]':
84 """
85 Applies function to the inner value.
86
87 Applies 'function' to the contents of the IO instance
88 and returns a new IO object containing the result.
89 'function' should accept a single "normal" (non-container) argument
90 and return a non-container result.
91
92 .. code:: python
93
94 >>> def mappable(string: str) -> str:
95 ... return string + 'b'
96
97 >>> assert IO('a').map(mappable) == IO('ab')
98
99 """
100 return IO(function(self._inner_value))
101
102 def apply(
103 self,

Callers 3

applyMethod · 0.95
mapMethod · 0.45
applyMethod · 0.45

Calls 1

IOClass · 0.85

Tested by

no test coverage detected