Skip to content

Instantly share code, notes, and snippets.

@DotNetNerd
Created May 8, 2013 08:54
Show Gist options
  • Save DotNetNerd/5539170 to your computer and use it in GitHub Desktop.
Save DotNetNerd/5539170 to your computer and use it in GitHub Desktop.
Sample of extension method in F#
namespace ExtensionFSharp
module CollectionExtensions =
type System.Collections.Generic.IEnumerable<'a> with
member this.ForEach(f:'a -> unit) =
for item in this do
f item
open System.Linq
open ExtensionFSharp.CollectionExtensions
let range = {1 .. 10}
range.ForEach(fun i -> printfn "%i" i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment