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
README showing "old style" init-based StringSpec #177
Comments
It's just a matter of preference rather than one being better I think. Personally I prefer the init block. |
OK, no problem. Can you tell us the reason for your preference for init over construction? (I want to present the most idiomatic KotlinTest code possible at DevoxxUK 2017 on Thursday.) |
@sksamuel I just reread https://discuss.kotlinlang.org/t/init-block-for-constructor-body/1703 does the above comment mean you have changed your position on the superclass constructor and init blocks? Fine if yes, I am just worrying about showing the most idiomatic code – but I already said that above I guess. |
In that discussion I was arguing we should just be able to do, class MyClass {
val writer = new Writer
writer.write("start")
fun foo = ...
} and dispense with the init block entirely. But as to your question, we don't have a position on which is clearer. I'm not even sure which style most people use. I use the init block purely because that's just the way I've always done it. If we had to pick I'd say the init block was the idiomatic way. @helmbold may have a stronger opinion. |
@sksamuel :-) |
Thanks. That works for me. I shall switch back to init blocks. |
Should the README show the newer style of StringSpec where the block is in the superclass constructor rather than an explicit init block?
The text was updated successfully, but these errors were encountered: