Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why in F# you can write String.Join but not string.Join?

Tags:

f#

In C# you can write string.Join and String.Join. But in F# you cannot write string.Join but only String.Join. Why is that? Is not string a type alias over .NET String class?

like image 577
Dragno Avatar asked Nov 16 '21 17:11

Dragno


People also ask

Why do s's look like F's?

Why in old English text was an 's' written as an 'f'? It wasn't; it was just written differently according to its position in the word. The f-like s (like an f without the crossbar) was a tall variant used at the start or in the middle of a word, which the modern s was used at the end or after a tall s.

Why is f used instead of E?

The F is considered separate as it denotes a failing grade, and does not need to go in alphabetical order. It just so happens that “fail” starts with a letter that skips one letter alphabetically on the scale. That said, E was used at one point.

What is called F?

F, f [Called 'eff']. The 6th LETTER of the Roman ALPHABET as used for English. It originated in the Phoenician symbol waw, a vertical line forking at the top like Y, which was adapted by the Greeks into two letters: ϝ (digamma: 'double gamma'), which represented the sound /w/, and Υ(upsilon), which represented /u/.


1 Answers

In F# string, depending on where it's used, is a type alias or a function:

string 12 // this stringifies '12'

let f (s: string) = ... // here 'string' is a type alias for 'System.String'

And so static members like Join don't sit on string. They are available via String. If you created your own alias, then you'd get access to the static members via ..

In C#, both string and String refer to the same System.String at all times.

like image 53
Phillip Carter Avatar answered Sep 29 '22 07:09

Phillip Carter