SML# Document Version 3.7.1
19 Expressions

19.11 Field update expression appexp # { exprow }

This is the expression that produces a new record obtained by updating the record denoted by appexp with fields specified in { exprow }. The type of this expression is same as that of appexp. The following shows an example.

# {x = 1, y = 2} # {x = 2};
val it = {x = 2, y = 2} : {x : int, y : int}

As seen in the following example, this expression has polymorphic type with respect to records.

# fun incX r = r # {x = #x r + 1};
val incX = fn : [’a#{x: int}. ’a -> ’a]
# incX {x = 1, y = 2};
val it = {x = 2, y = 2} : {x : int, y : int}