This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how do you make instantiate multiple objects with one statement inside a loop?  RSS feed

 
Luke Stanley
Greenhorn
Posts: 4
Opera Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I need to know how one can make objects with one statement inside a loop. I am writing a card game program, and i COULD go


ect, but that seem extraordinarily inefficient. Is there a way I can change this for loop to make the cards? this is what i have so far:

but I do not know what to put for that statement. Is there a way to do this?

Thank you,
Luke
 
Luigi Plinge
Ranch Hand
Posts: 441
IntelliJ IDE Scala Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make an array

or List

 
Luke Stanley
Greenhorn
Posts: 4
Opera Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ahhhh ok. Thanks much! also just noticed i left out the third for statement thingy.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!