<How order1.addItem(Noodles()) line from main cons...
# stackoverflow
u
How order1.addItem(Noodles()) line from main considers that Noodle() instance is same as Item() instance. For me Noddle &amp; Item instance are diff Kotlin, In this I have a parent class called Item and two sub classes derived from it are Noodles & Vegetable. Then i have created an Order class which has addItem method which accepts Item of type ITEM. Then i have a main function. In main function i am trying to add an item by passing Noodle instance. Code is running fine but i am not able to understand that function is suppose to accept parameter of type Item but it is working fine with Noodle instance, how. Both instance are different...