Accessing element from reference array in F# -


was experimenting arrays , references - intent create reference array , use reference inside closure access element of array. fsi attempt:

> let dk2 = array.create 5 0 let dk2ref = ref dk2;;  val dk2 : int [] = [|0; 0; 0; 0; 0|] val dk2ref : int [] ref = {contents = [|0; 0; 0; 0; 0|];}  > !dk2ref.[1]  stdin(3,2): error fs0039: field, constructor or member 'item' not defined 

is there direct way access element of referenced array? (in case, 2nd element of dk2ref)?

i'm not sure why need reference array.

looking operator precedence table, . operator has higher precedence ! operator. example parsed !(dk2ref.[1]) causes error because 'a ref doesn't implement indexed properties.

you need add parentheses @ right places:

> (!dk2ref).[1] val : int = 0 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

java - How to create Table using Apache PDFBox -

c# - Attempting to upload to FTP: System.Net.WebException: System error -