Table of Contents

Class MapExtensions

Namespace
FunctionalDdd
Assembly
FunctionalDdd.RailwayOrientedProgramming.dll

Provides extension methods for mapping (transforming) values inside Result objects.

public static class MapExtensions
Inheritance
MapExtensions
Inherited Members

Remarks

Map is used when you have a function that always succeeds and you want to transform the value inside a Result without changing its success/failure state. Unlike Bind, Map functions don't return a Result - they return a plain value that gets automatically wrapped in a success Result. If the input Result is a failure, the Map function is skipped and the failure is propagated.

Methods

Map<TIn, TOut>(Result<TIn>, Func<TIn, TOut>)

Maps the value of a successful result to a new value using the provided function. If the result is a failure, returns the failure without calling the function.

public static Result<TOut> Map<TIn, TOut>(this Result<TIn> result, Func<TIn, TOut> func)

Parameters

result Result<TIn>

The result to map.

func Func<TIn, TOut>

The function to transform the value if the result is successful.

Returns

Result<TOut>

A new success result with the transformed value if success; otherwise the original failure.

Type Parameters

TIn

Type of the input result value.

TOut

Type of the output result value.