Note that there are some explanatory texts on larger screens.

plurals
  1. POStatic Member Indexed Properties
    primarykey
    data
    text
    <p>Is it possible to create static member indexed properties in F#? <a href="http://msdn.microsoft.com/en-us/library/dd233202.aspx" rel="nofollow">MSDN</a> show them only for instance members, however, I'm able to define the following class:</p> <pre><code>type ObjWithStaticProperty = static member StaticProperty with get () = 3 and set (value:int) = () static member StaticPropertyIndexed1 with get (x:int) = 3 and set (x:int) (value:int) = () static member StaticPropertyIndexed2 with get (x:int,y:int) = 3 and set (x:int,y:int) (value:int) = () //Type signature given by FSI: type ObjWithStaticProperty = class static member StaticProperty : int static member StaticPropertyIndexed1 : x:int -&gt; int with get static member StaticPropertyIndexed2 : x:int * y:int -&gt; int with get static member StaticProperty : int with set static member StaticPropertyIndexed1 : x:int -&gt; int with set static member StaticPropertyIndexed2 : x:int * y:int -&gt; int with set end </code></pre> <p>But when I try to use one, I get an error:</p> <pre><code>&gt; ObjWithStaticProperty.StaticPropertyIndexed2.[1,2] &lt;- 3;; ObjWithStaticProperty.StaticPropertyIndexed2.[1,2] &lt;- 3;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error FS1187: An indexer property must be given at least one argument </code></pre> <p>I tried a few different syntax variations and none worked. Also weird is that when I hover over <code>set</code> in VS2010 for one of the definitions in the type, I get info about <code>ExtraTopLevelOperators.set</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload