Option.defaultValue

Two Fer
Two Fer F# ট্র্যাকে
let twoFer (nameOpt: string option): string =
    let name = Option.defaultValue "you" nameOpt
    $"One for {name}, one for me."

We use the Option.defaultValue function which either returns the value within the Option<T> value passed to it, or else returns the default value we pass to it ("you").

We then use string interpolation to build the return string where {name} is replaced with the name we just found.

String formatting

The string formatting article discusses alternative ways to format the returned string.

14 অক্টোবর 2026 · কাজে লেগেছে?

F# ট্র্যাকে Two Fer অনুশীলনীর অন্য অ্যাপ্রোচগুলো

এই অনুশীলনীটি আমাদের কমিউনিটি যেভাবে অন্য ভাবেও সমাধান করেছে