• Post Reply Bookmark Topic Watch Topic
  • New Topic

Object[] contents  RSS feed

 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a method that returns an object array containing a list and an integer.






The above code is invoked by


//where qs is the list and j is the integer.

Thus fin[] contains a list and an integer.
How can i separate them?
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not put them together in the first place?
rec[0], rec[1]?

An untyped collection can only be used by the programmer remembering which order the contents are in. You would have to remember you have a List and an Integer. Now you can see what flaky, brittle code that is.
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Campbell Ritchie

Not put them together in the first place?
rec[0], rec[1]?


Something like // i am missing something, that's for sure. It can't be this.

An untyped collection can only be used by the programmer remembering which order the contents are in. You would have to remember you have a List and an Integer. Now you can see what flaky, brittle code that is.


Yes,It is. There would be any other way out
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, that is not what I meant. I meant use rec[0] to retrieve the List and rec[1] to retrieve the Integer. Of course, it is probably bed design to mix those two like that in an array. Why don’t you return an object designed to encapsulate details of both those references?
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Campbell Ritchie for your valuable suggestions.
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You’re welcome
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!