But I typically only use semi-colons to separate inline items. Here is an array example. Notice the last item can have an optional separator on the end:
letstoryPoints=[|1;2;3;5;8;13;21;|]
Since either works as a separator, you can also use both.
letboard=[O;X;OX;X;OX;O;X]
You can also turn it into the Elm-like syntax if you really want.
I'm not a fan of this because cutting/pasting the first line gets weird (e.g. moving it to the bottom). Git can also get confused when you swap the first line for another and merge with someone else's changes.
Note: F# actually requires commas for tuples. Probably because tuples are defined with parens, which would be hard to disambiguate from an expression with newlines.
That git requirement/problem is in my mind. I'd like to ensure that the source files are source control friendly.
I never thought about using ; to separate lists, though there's no real reason why I would distinguish between ; and ,. Just a classic syntax I guess, though semi-colons seem "heavier" than commas.
In the rare occasion that I have inline list elements, I instinctively use commas then have to go back and replace with semi-colons. The compiler thinks I have one list item that is a tuple, since commas indicate tuples in F# (even without parens).
I do like the range of choices that are given by using either a separator char or newline. However in practice, I nearly always use the first style (newlines only). It is the most copy-paste and git friendly, and secondarily I like the visual flow.
I think the inline versus multiline choice depends on what type of code you are writing. Anything that involves a logical list of items I prefer newlines.
var items = [
item_one,
item_two(args),
1 + 2,
]
But, sometimes I have little tuples, like points, that would be burdensome, and unclear to do multiline:
var a : point = [1,2]
var b = pt_a + [3,4]
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I like the way F# supports both
\n
and;
as separators for lists and arrays. (I do wish it were comma instead of semi-colon.)Here's a list example.
oneOf
is given a list with 3 items.stopWith
is given a list with 2 items.But I typically only use semi-colons to separate inline items. Here is an array example. Notice the last item can have an optional separator on the end:
Since either works as a separator, you can also use both.
You can also turn it into the Elm-like syntax if you really want.
I'm not a fan of this because cutting/pasting the first line gets weird (e.g. moving it to the bottom). Git can also get confused when you swap the first line for another and merge with someone else's changes.
Note: F# actually requires commas for tuples. Probably because tuples are defined with parens, which would be hard to disambiguate from an expression with newlines.
That git requirement/problem is in my mind. I'd like to ensure that the source files are source control friendly.
I never thought about using
;
to separate lists, though there's no real reason why I would distinguish between;
and,
. Just a classic syntax I guess, though semi-colons seem "heavier" than commas.In the rare occasion that I have inline list elements, I instinctively use commas then have to go back and replace with semi-colons. The compiler thinks I have one list item that is a tuple, since commas indicate tuples in F# (even without parens).
I do like the range of choices that are given by using either a separator char or newline. However in practice, I nearly always use the first style (newlines only). It is the most copy-paste and git friendly, and secondarily I like the visual flow.
I think the inline versus multiline choice depends on what type of code you are writing. Anything that involves a logical list of items I prefer newlines.
But, sometimes I have little tuples, like points, that would be burdensome, and unclear to do multiline: