Warning produced by f#: value has been copied to ensure the original is not mutated
Posted
by
user1878761
on Stack Overflow
See other posts from Stack Overflow
or by user1878761
Published on 2012-12-06T21:54:45Z
Indexed on
2012/12/06
23:04 UTC
Read the original article
Hit count: 181
F#
The first definition below produces the warning in the title when compiled with f# 3.0 and the warning level set to 5. The second definition compiles cleanly. I wondered if someone could please explain just what the compiler worries I might accidentally mutate, or how would splitting the expression with a let clause help avoid that. Many thanks.
let ticks_with_warning () : int64 =
System.DateTime.Now.Ticks
let ticks_clean () : int64 =
let t = System.DateTime.Now
t.Ticks
© Stack Overflow or respective owner