Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tupleOf with overloads ["Request"] #3343

Open
gabrieljones opened this issue Jan 5, 2024 · 2 comments
Open

tupleOf with overloads ["Request"] #3343

gabrieljones opened this issue Jan 5, 2024 · 2 comments

Comments

@gabrieljones
Copy link

gabrieljones commented Jan 5, 2024

What version are you currently using?
1.2.1

What would you like to see?

fun <A, B>tupleOf(first: A, second: B) = Pair(first, second)
fun <A, B, C>tupleOf(first: A, second: B, third: C) = Triple(first, second, third)
fun <A, B, C, D>tupleOf(first: A, second: B, third: C, fourth: D) = Tuple4(first, second, third, fourth)
fun <A, B, C, D, E>tupleOf(first: A, second: B, third: C, fourth: D, fifth: E) = Tuple5(first, second, third, fourth, fifth)
fun <A, B, C, D, E, F>tupleOf(first: A, second: B, third: C, fourth: D, fifth: E, sixth: F) = Tuple6(first, second, third, fourth, fifth, sixth)
//... etc
@gabrieljones
Copy link
Author

gabrieljones commented Jan 5, 2024

I see all of these have toList(): List<T> but there is no way to call toList polymorphically due to lack of structural subtyping/type classes/ducktyping in kotlin. 🤦 I am a Kotlin newbie so maybe I am wrong?

@serras
Copy link
Member

serras commented Jan 17, 2024

The main issue I see with this is that there's no much difference between writing tupleOf(a, b, c) and Triple(a, b, c).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants