Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Does Alice support polymorphism?

Alice polymorphism support
0
10 Posted

Does Alice support polymorphism?

0

polymorphism Unfortunately, Alice does not support this sort of functionality directly. There are a few ways around this, but they aren’t nearly as elegant as the solution you’re looking for. The first way to do this is to write a method external to the objects in the list (off of world) that takes an object as a parameter. If then go to any object’s questions and scroll down to “other”, you’ll find the question called “object”‘s part named “key”. This question lets you any part on an object–whether it’s there or not (it will throw an error if you try to reference a part that doesn’t exist, so be aware of that when using it). You can then write a generalize method that takes in any given chicken and has it look for food. If you don’t want to deal with the “part named” question, then the other option is to write a similar function but use if/else statements to determine which chicken is passed in.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123