For example I want to declare
let len, (*mutable*) i =
if s.Length >= 2 && s.[0] = '0' && (s.[1] = 'x' || s.[1] = 'X') then
(s.Length - 2, 2)
else (s.Length, 0)
constant binding len and mutable i, is it possible ?
Added : I will use references开发者_开发技巧 then
let len, i =
if s.Length >= 2 && s.[0] = '0' && (s.[1] = 'x' || s.[1] = 'X') then
(s.Length - 2, ref 2)
else (s.Length, ref 0)
No. mutable
applies to the entire let
binding. You'll have to do:
let len, i = ...
let mutable i = i
精彩评论