1 people like it.

Default parameter value. Useful for ASP.NET controllers

Usage: [] member __.Image (image, DefaultValue 1024 width, DefaultValue 768 height)

1: 
2: 
3: 
4: 
5: 
let (|DefaultValue|) (defaultValue: 't) (input: 't) =
    if obj.Equals(input, Unchecked.defaultof<'t>) then 
      defaultValue 
    else 
      input 
Multiple items
type DefaultValueAttribute =
  inherit Attribute
  new : unit -> DefaultValueAttribute
  new : check:bool -> DefaultValueAttribute
  member Check : bool

Full name: Microsoft.FSharp.Core.DefaultValueAttribute

--------------------
new : unit -> DefaultValueAttribute
new : check:bool -> DefaultValueAttribute
val defaultValue : 't
val input : 't
type obj = System.Object

Full name: Microsoft.FSharp.Core.obj
System.Object.Equals(objA: obj, objB: obj) : bool
module Unchecked

from Microsoft.FSharp.Core.Operators
val defaultof<'T> : 'T

Full name: Microsoft.FSharp.Core.Operators.Unchecked.defaultof
Raw view Test code New version

More information

Link:http://fssnip.net/7Vg
Posted:5 years ago
Author:Yuri Martynov
Tags: #active patterns , asp.net , pattern matching