-
Notifications
You must be signed in to change notification settings - Fork 6.1k
KT-20357: Add sample usages for array constructor functions #5521
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
base: master
Are you sure you want to change the base?
KT-20357: Add sample usages for array constructor functions #5521
Conversation
|
Hi, just checking if I need to do anything else to move this toward review |
| /** | ||
| * Returns an array containing the specified [Double] numbers. | ||
| * | ||
| * @sample samples.collections.Arrays.Constructors.doubleArrayOf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update corresponding actual declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did it in a74af86
Let me know if that's what you wanted
| class Constructors { | ||
| @Sample | ||
| fun doubleArrayOf() { | ||
| val doubleArray = doubleArrayOf(1.0, 2.5, 3.14) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might make sense to showcase that these functions produce an empty array when invoked without any arguments. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Samples for array functions have been added as requested(Ref a74af86). I renamed the sample methods with a 'Sample' suffix to prevent recursive self-calls, but let me know what you think
| * Returns an array containing the specified elements. | ||
| */ | ||
| public expect inline fun <reified T> arrayOf(vararg elements: T): Array<T> | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also makes sense to add a similar sample for arrayOf ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done on b49f96e
…rd library Related issue: KT-20357
…tions in standard library Related issue: KT-20357
0713c9e to
bbe6420
Compare
Related issue: KT-20357
bbe6420 to
b49f96e
Compare
Added a sample function for constructors in
Library.kt.These are just the basics, but I remember when I was learning Kotlin that having examples for everything would’ve made me spend more time in the official documentation.
Related issue: KT-20357