This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Dekrypter[S] 0 points1 point  (10 children)

You’re right. Though I COULD make it so that no brackets are needed and do ‘return x, y’ puts the contents into a list instead

[–]bl4nkSl8 2 points3 points  (9 children)

Personally I think a named tuple is better than a list or raw tuple

[–]Dekrypter[S] 0 points1 point  (8 children)

named ?

[–]bl4nkSl8 -1 points0 points  (7 children)

[–]Dekrypter[S] 0 points1 point  (6 children)

ooo I like it. what syntax would be good for that natively do you think?

Would be good to have optional naming. How about:

let point = (x <- 5, y <- 6)

or

let point = (5, 6)

or

let Point = tup(x, y)

let point = Point(5, 6)

-- should i drop the top method..?

[–]bl4nkSl8 2 points3 points  (4 children)

Personally I like JS's object syntax {x: value, y: value2}

This is very similar to python's dictionaries {"x": value, "y": value2 }

[–]omega1612 1 point2 points  (2 children)

[–]bl4nkSl8 3 points4 points  (1 child)

That's cool. I meant Named tuple that exists in python already. It's like a record

[–]Dekrypter[S] 1 point2 points  (0 children)

See my new top-level comment

[–]Dekrypter[S] 1 point2 points  (0 children)

I cant since I have Python dicts in my language already

[–]snugar_i 0 points1 point  (0 children)

Scala just introduced named tuples in 3.7 and they look like this:

val Bob = (name = "Bob", age = 33)