Quite new to functional languages, but I'm maintaining someone else's code with a lot of F#. Can anyone offer some insight into this?
let mtvCap = Rendering.MTViewerCapture(mtViewer)
mtvCap.GetCapture()
mtvCap.ToWpfImage()
grid.Children.Add(mtvCap.ImageElement)
MTViewer.ImageViewer is of type System.Windows.Controls.Image, and grid is System.Windows.Controls.Grid.
Again, error is: The type int is not compatible with type unit
F# does not allow for you to silently ignore return values. The type
unitis F#'s version ofvoid. So the error is saying essentiallyOr the opposite. I tend to incorrectly read this error message.
What's likely happening is one of the following
intreturn value but the methodAddreturns void hence F# is just asking for a return valueunitbutAddis returning anintand F# needs you to ignore the value.GetCaptureorToWpfImagereturn values that need to be explicitly handled.For the last 2 cases you can fix this by passing the value to the
ignorefunctionAfter digging around a bit I believe #2 is the issue because
UIElementCollection.Addreturns anintvalue. Try modifying the final line to look like this