Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

add methods ?  RSS feed

 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i add methods?
example : can it happen this?and the result of it will be 14?
 
Tim Cooke
Marshal
Posts: 3856
233
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could answer this simply enough by running the code yourself. Try it out and report back with your results.
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Cooke wrote:You could answer this simply enough by running the code yourself. Try it out and report back with your results.
worked :d
 
Tim Cooke
Marshal
Posts: 3856
233
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great! What was the value of k at the end? 14 as you predicted?
 
Fred Kleinschmidt
Bartender
Posts: 560
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And sinc you found out that it worked, what do you think this would produce?
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fred Kleinschmidt wrote:And sinc you found out that it worked, what do you think this would produce?
the same?
 
Tim Cooke
Marshal
Posts: 3856
233
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you asking? Or telling?

Try it out yourself, and tell us what the result is. You learn by doing, so many questions can be answered with a little test program where you play with the code and see what happens.
 
Tyson Lindner
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ekte spiriopoulos wrote:can i add methods?


Its more like you're adding/storing the results of those methods.
 
Roel De Nijs
Sheriff
Posts: 11338
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ekte spiriopoulos wrote:can it happen this?and the result of it will be 14?

Without the method declarations (and especially the return types) of add() and addk(), it is impossible to tell if it will compile or not... And to illustrate, some of these add() methods will compile, others will not. It's up to you to determine which ones will compile and which others won't (and try to explain why), if you insert them independently
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!