Rhywun (23) [Avatar] Offline
The getInitials function doesn't work the way I would expect:

let getInitials customer = customer.FirstName.[0] + customer.LastName.[0]

When I call it with my name I want to see "PH" but instead I get:

val it : char = '\152'

And the signature is

customer:Customer -> char

How do I get it to return actual initials? Thanks
Isaac Abraham (68) [Avatar] Offline
Argh! You're right. This code is wrong, and I've fixed it for the next release (unfortunately it's just missed the next MEAP).

The correct code is either: -

let getInitials customer = customer.FirstName.[0], customer.LastName.[0]

which returns a char * char Tuple, or

let getInitials customer = System.String [| customer.FirstName.[0]; customer.LastName.[0] |]

Which creates a new string, using the two chars as an input array to String (same as C#).

Great spot.