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

Declaring methods with parameters  RSS feed

 
christopher pam
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,is it possible to declare the parameter list of a method with more than one type like say "public void displayMessage(String courseName.Int courseGradePointAverage)"?
 
Rao Raghu
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

(String courseName.Int courseGradePointAverage)


Is it a dot? I suppose it should be read as a comma, right?
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can not do that. Rename the method. You can however reorder the parameters so that it is overloaded but that would be a very bad idea. Infact a very very bad idea. :roll: Just take it as a warning rather than a suggestion.
 
Campbell Ritchie
Marshal
Posts: 55682
162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have people misunderstood Christopher Pam's original question?
Does it mean, "Can you have two parameters to a method?" To which the answer is yes. It should however (as Raghu Rao has implied) read:-. . . and welcome to the Ranch.
[ March 09, 2007: Message edited by: Campbell Ritchie ]
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Campbell for pointing that out. Never thought it that way. Well then then Rao and Campbell have already answered.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!