Yes, it does. super is most useful when over-riding the behavior from a method provided in the ancestor chain. I would revise the example to the following:
classMomPBTechniquedefcorner_cut(bread)forcornerinbreadcorner.cutcrustendreturnbreadendclassMyPBTechnique<MomPBTechnique# I like *one* corner to not be cut!defcorner_cutfirst_corner=self.bread[0]# Gets the first cornerself.bread=bread.slice(1,-1)# Sets the bread to only the last 3 cornerssuper# Calls the `corner_cut` method defined in `MomPBTechnique`returnbread.unshift(first_corner)# Places the un-cut first corner back in the breadendend
This more clearly demonstrates how super can be used to re-use-but-still-change behavior in the class hierarchy.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Doesn't doing
B-PB-Technique < Mom-PB-Tecnhnique
already give you all of mom's methods?Yes, it does.
super
is most useful when over-riding the behavior from a method provided in the ancestor chain. I would revise the example to the following:This more clearly demonstrates how super can be used to re-use-but-still-change behavior in the class hierarchy.