DEV Community

Discussion on: Write a function that shows off something unique or interesting about the language you're using

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

In F# it is also easy to add functionality to existing classes.

type String with

    member me.yell () =
        me.ToUpper() + "!!!"

You can also add functions to existing static classes (modules) too.

module Array =
    let shuffle arr =
        ...

[| for i in 0 .. 23 do yield i * i |]
    |> Array.filter isOdd   // filter is built-in
    |> Array.shuffle        // i added