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
Added writing a row from variable number of arguments #51
Added writing a row from variable number of arguments #51
Conversation
Codecov Report
@@ Coverage Diff @@
## master #51 +/- ##
============================================
+ Coverage 95.49% 95.56% +0.06%
- Complexity 145 146 +1
============================================
Files 21 21
Lines 822 834 +12
Branches 65 65
============================================
+ Hits 785 797 +12
Misses 15 15
Partials 22 22
Continue to review full report at Codecov.
|
* write one row | ||
*/ | ||
override fun writeRow(vararg entry: Any) { | ||
writeRow(entry.toList()) |
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.
Do you think it is better to specify explicitly the implementation, so it would not look like cyclic?
override fun writeRow(vararg entry: Any) {
willWritePreTerminator()
writeNext(entry.toList())
willWriteEndTerminator()
if (writer.checkError()) {
throw IOException("Failed to write")
}
}
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.
No, I don't think. Leave this as it is.
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.
Thanks for giving your thoughts.
Thanks a lot @blackmo18 , but in my sense, it's a little awkward to receive vararg arguments as data. And as another reason, I can't come up with useful usecase to use this API. |
Yes, I think also it doesn't make sense in writing a large volume of entries in a file. On the other hand for small files, scripting, creating and exporting data models, and for testing purposes, it could be quite handy. if you agree on this, I'll change the method signature into |
OK, let's do so. Please go ahead and proceed with it. |
Also update README please. Line 159 in 36e8cb8
|
…to feature/write-csv-row-from-variable-arguments
- include a sample in writing a row from variable arguments
Hi @doyaaaaaken , already updated README and changed the method signature. |
I think to be able to write a variable number of arguments is nice also without creating a list before hand.
example:
Although Kotlin already supports a variable argument in instantiating a list with initial values, I think this one will be cleaner and less boiler plate on the user end.