Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

another way to write this

 
Gabriel White
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is another way to write this without the ? and : ???



interFace is an array of 2 strings
superClass is an array of 2 strings
c is an object of the Class class.

I know that there is a way to do an if statement around this, but I don't want to hose my parameter list.

Thanks in advance.
 
Gabriel White
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it basically if it is an interface (true) then just param the c as an interface and if not (else) then send in the superClass (true)???

Thanks
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
c = a ? b : d;

is the same as

if (a)
c = b
else
c = d

So you would have different method calls based on the condition c.isInterface()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic