Let and Property Assignment in one line
f#, properties, variable-assignment
Solution
I don't recommand you to write it on a single line because this means it will be a mix between the #light (the mode by default now) and non #light syntax. If you really need to, you can use ;; like that:
open System
open System.Windows.Forms
let mainForm = new Form()
let contextMenu = new ContextMenuStrip();; mainForm.ContextMenuStrip <- contextMenu;;
If your expressions have unit type you can use a Sequential Execution Expression, which is an expression of the form:
expr1; expr2; expr3
for instance:
mainForm.ContextMenuStrip <- contextMenu; 5 + 6 |> ignore; mainForm.ContextMenuStrip <- null
I'd like to add that Sequential Execution Expressions have nothing to do with the non #light mode. They are just a general language construct.
Hope it helps.
Problem
How can you write the following F# code (or similar) in one line: ``` let contextMenu = new ContextMenuStrip() mainForm.ContextMenuStrip <- contextMenu ``` I have to declare contextMenu as it will be needed later.