Legacy name: Baby Name Meaning, Origin and Popularity
Posted onLegacy — Baby girl name meaning, origin, and popularity
Legacy —
Baby girl name meaning, origin, and popularity | BabyCenter
- Community
- Getting Pregnant
- Pregnancy
- Baby Names
- Baby
- Toddler
- Child
- Health
- Family
- Courses
- Registry Builder
- Baby Products
Advertisement
Legacy name popularity
Popularity over time
babies per million
Source: Social Security Administration & BabyCenter user data
Advertisement | page continues below
Similar names to Legacy
like Legacy? What about:
Nova
Serenity
Lyric
Royalty
Harmony
Journee
Reign
Leilani
Dream
Journey
Willow
Kehlani
Common sibling names
Brothers
Legend
Baby name lists including Legacy
-
149 unique baby names
By Betsy Shaw
Baby Names A-Z
A
Baby girl names that start with A
B
Baby girl names that start with B
C
Baby girl names that start with C
D
Baby girl names that start with D
E
Baby girl names that start with E
F
Baby girl names that start with F
G
Baby girl names that start with G
H
Baby girl names that start with H
I
Baby girl names that start with I
J
Baby girl names that start with J
K
Baby girl names that start with K
L
Baby girl names that start with L
M
Baby girl names that start with M
N
Baby girl names that start with N
O
Baby girl names that start with O
P
Baby girl names that start with P
Q
Baby girl names that start with Q
R
Baby girl names that start with R
S
Baby girl names that start with S
T
Baby girl names that start with T
U
Baby girl names that start with U
V
Baby girl names that start with V
W
Baby girl names that start with W
X
Baby girl names that start with X
Y
Baby girl names that start with Y
Z
Baby girl names that start with Z
A
Baby boy names that start with A
B
Baby boy names that start with B
C
Baby boy names that start with C
D
Baby boy names that start with D
E
Baby boy names that start with E
F
Baby boy names that start with F
G
Baby boy names that start with G
H
Baby boy names that start with H
I
Baby boy names that start with I
J
Baby boy names that start with J
K
Baby boy names that start with K
L
Baby boy names that start with L
M
Baby boy names that start with M
N
Baby boy names that start with N
O
Baby boy names that start with O
P
Baby boy names that start with P
Q
Baby boy names that start with Q
R
Baby boy names that start with R
S
Baby boy names that start with S
T
Baby boy names that start with T
U
Baby boy names that start with U
V
Baby boy names that start with V
W
Baby boy names that start with W
X
Baby boy names that start with X
Y
Baby boy names that start with Y
Z
Baby boy names that start with Z
Advertisement | page continues below
Baby Names Generator
Our Baby Name Generator helps you find the perfect name, sorted by gender, letter, meaning, and more. You don’t need to fill out every field, just the ones you’re interested in.
About the name structure
I am looking for a
name starting with
Letter
Letter
and ending with
Letter
Letter
with
syllables.
About the name meaning
The name means
Meaning
Meaning
and the theme is
.
The origin is
.
Learn more about a name
My pregnancy week by week
Advertisement
Legacy Name Meaning — Origin, Religion of Baby Unisex Name Legacy
What does the name Legacy mean? What is the meaning of the name Legacy?
Meaning of Legacy: Name Legacy in the English origin, means Heritage, Legacy, What a person leaves behind. Name Legacy is of English origin and is a Unisex name. People with name Legacy are usually Judaism by religion.
Create your Own Baby Names List
Add baby names to your favourite list.
Now you can add this or any baby name on TheParentZ.com to your favourite list. Our largest baby name lists database is the best place for you to keep track of your favourite names. To finalize the name of your baby, Save all your selected favourite names at one place. You can also share the list with your family and friends.
Click on the heart next to baby names to add name to your favourite list. Start adding your favourite names to create your list!
Meaning
Heritage, Legacy, What a person leaves behind
Syllable
3
Characters
1 word with 6 characters
Spell
Phonetic
Pythagorean Numerology
8
Indian Vedic Numerology
6
Nakshatra (Birth Star)
Bharani
Rashi
Do you know the meaning of the name Legacy?
Tell us what Legacy means to you
More Information About Legacy
Related Names
Related / Similar Names
Popular names beginning with ‘L’
Sibling Names
Popularity & Ratings
Famous People
Origin & Meanings
User Submitted Origins
Other Details
Numerology
Spell in Other Languages
Baby Name Poster
Comments
FAQs
- Boy Names
- Girl Names
Starts withEnds with
Meaning and Origin
Submit the origin and/or meaning of Legacy to us below
What is the meaning of Legacy?
Fill out the form and tell us what baby name Legacy means to you. You can also use the form to suggest alternate meanings of the name or the meaning of the name in your culture/country.
Tell us what Legacy means
Origin of LegacyAfricanAboriginalAfghanAkanAlaskanAlbanianAlgeriaAncient ArabicAncient GermanicAncient GreekAncient RomanAncient ScandinavianAngloAnglo BritishAnglo FrenchAnglo NormanAnglo SaxonArabicAramaicArgentinaArican HausaArmenianArthurianArthurian RomanceAshkenazi JewAssameseAssyrianAustralianAustriaBabylonianBagandaBahamasBantuBasqueBelgianBengaliBhutaniBiblicalBosnianBotswanianBrazilianBritianBritishBulgarianBurmeseCambodianCatalanCelticChamorroChineseChristianityChumashCornishCroatianCyprusCzechDanishDominican RepublicEast IndianEastern AfricanEgyptianEnglishEstonianEthiopianEtruscanEweFarsiFilipinoFinnishFlemishFrisianGaelicGaulsGermanGermanicGhanaGothicGreat BritainGreeceGreek MythologyGreek PolytheismGreenlandicGujaratiHaitianHawaiianHebrewHindiHinduHispanicIberianIbibioIcelandicAmericanIndo SaxonIndonesianInuitIranianIrishIsraeliItalianJamaicanJapaneseJewishJudaismKannadaKazakhKikuyuKoreanKurdishLate RomanLatinLatvianLebaneseLiteraryLithuanianMacedonianMalagasyMalayMalayalamMalianMandrinManxMaoriMapucheMarathiMedieval EnglishMiddle EastMiwokModern GreekMoldavianMongolianEastern EuropeanNahuatlNative AmericanNdebeleNepaliNew ZealandNigerianNordicNormanNorman FrenchNorseNorwayNorwegianOld ArabicOld EnglishOld FrenchOld GreekOld NorseOld NorwegianOld ProvencalOld WelshOriyaPacific IslandsPakistanPaliParsiPersianPhilippinesPhoenicianPolishPolynesianPunjabiQuranicRomanRoman MythologyRoman PolytheismRussianSanskritSaxonScandinavianScottishSemiticSerboShakespeareanShawneeShonaSicilianSikhSindhiSinhalaSiouxSlavicSlovakSloveneSomaliSouthern AfricanSri LankaSwahiliSwedishSwissSyriaTamilTartarTeluguTeutonicThaiTheodoricTigristiTonganTorahTswanaTupiTurkishIndianVietnameseVirginaWelshWelsh MythologyWest GothicYiddishYorubaYucatec MayaZapotecZimbabweanZuluFrenchIgboMexicanSpanishUrduAfrican AmericanAncient EgyptianAnglo AmericanArabic FrenchArthurian LegendAztecBeothukBretonsCanadianColumbianDutchEnglandEsperantoFijanGeorgianGreekGypsyHungarianIndo EuropeanJainismKenyanLatin AmericaMalawiMapudungunMiddle EnglishMythologyNetherlandsNorse MythologyOld GermanOld RomanPashtoPortugueseRomanianSerbianSindarinSouth IndianTahitianTibetianUkrainianUnited StatesUrhoboWestern African
GenderUnisexGirlBoy
How to write Legacy in origin (native) alphabets
Example: Arun of Sanskit origin — [ अरुण ]
How to Pronounce Legacy (Phonetic Spelling)
Example: Arun of Sanskit origin — [ ARR-UHN ]
Where did you hear about the name?
Keep me anonymous
Reset
Related names or Similar Names
Like Legacy? What about
Explore names with meaning similar to baby name Legacy: Heritage, Legacy, What a person leaves behind
Popular names also beginning with ‘L’
Lovepreet |
Loving and an affectionate person | Boy |
Likith |
Written; Learned; One who is well versed in writing | Boy |
Lovelyn |
A loved and cherised one | Girl |
Lawliet |
Name of the character in the Japanese series Death Note. |
Boy |
Lahan |
Lahan means Little Bright-Headed One | Boy |
Need a Sibling name for Legacy?
Use our Sibling name generator to find matching brother and sister names (boy or girl names) for
the baby name Legacy. Here is a list of Sibling names that go with Legacy
Common sibling names for Legacy
SISTERS: Sibling Sister names for Legacy
BROTHERS: Sibling Brother names for Legacy
Famous people with name Legacy (Namesakes)
Do you know any famous people named Legacy, let us know and we would update the information.
Want a different name?
Try our baby name generator. You can combine two names to find matching names. Using this Tool Parents can get their Child name similar or combination of their names. You can also get completely random names.
Bharani Nakshatra (Birth Star) — Characteristics and Details
Pythagorean Numerology (Western Numerology) — 8
Baby Name Legacy Numerology: Name Legacy has a number value of
8 as per Pythagorean Numerology (Western Numerology), its advised
that you also calculate ‘number value’ of name by entering full name in our Name Numerology Calculator.
Learn how to Spell Legacy Name in Other Languages
Learn how to Spell Legacy Name in Nautical Flags
Legacy
Learn how to Spell Legacy Name in Sign Language
Legacy
Learn how to Spell Legacy Name in Braille Alphabets (Grade 1)
Learn how to Spell Legacy Name in Morse Code
Legacy
Baby Name Poster
Please choose a template to generate name poster for Legacy
BabyNameComments
0 comments
Post your comments
Type your comments here…
Frequently Asked Questions (FAQs) about name Legacy
What is the numerology of baby name Legacy?
Name Legacy has numerology 6 as per The ParentZ.
What is the Nakshatra of Legacy?
Name Legacy belongs to Bharani nakshatra based on Indian Astrology or Janam Nakshatra as per the information available on The ParentZ.
What does Legacy mean?
Name Legacy means Heritage, Legacy, What a person leaves behind as per The ParentZ
What is the meaning and origin of the baby name Legacy?
Legacy means Heritage, Legacy, What a person leaves behind and is a English name given to Unisexs as per The ParentZ
How can I suggest alternate meaning of the name Legacy?
You can use our suggest meaning and origin form to suggest alternate meaning of the name
Legacy.
Chapter 579: Inherited Name | Level Up Legacy
His father seemed tired and unhappy, but Arthur had little effect. If that were in the past, a slight change in the kind father’s temperament would be enough to frighten Arthur. After all, his beloved parent may be disappointed.
«Now you call me father,» Seref said, turning to the window. “I never raised my son in such disrespect. You had one job, Arthur, and you decided to do whatever the hell you wanted.»
«After all, I am the creator.»
«I made you like this!» his father roared, banging his fist on the chair. «I am the source of your strength, but you didn’t bother to thank me for it!»
— You are the source of my suffering, father, — Arthur answered dispassionately, approaching the man. «And you think screaming will frighten me, you pathetic fool?»
Arthur’s words made his father start and look at him in surprise. It never occurred to him that his son could be so ruthless and unforgiving, but Arthur is not the same as before.
What he learned and the sacrifices he made changed him. His last meeting with his father affected him the most, but at that time, he put his heart into promoting his runic achievements. In the end, Arthur had to follow a new belief in destroying his feelings, not his emotions.
“I’m not an enemy, Arthur,” my father frowned, gritting his teeth and sighing. «I’m trying to get the best possible ending.»
«You don’t care about the damage you cause for the future,» said Arthur, pulling up a chair to sit next to him. “Tell me, father, what have you done during this time? What other mess do I need to fix?»
«This arrogance will bring doom to all of us,» the father rocked the chair back and forth. “I wanted to give you everything you need, all the resources and reasons for your ascension. But instead, you pursued the illusion of freedom.»
«Our reality is just an illusion that we accept,» Arthur said with a slight smile on his face. “You live in the illusion of glory and purpose. You knew you could never be more than just a vessel, and that’s the reason for it all.»
«All this?»
“The pursuit of fame is nothing but a goal, and it’s not even yours. It belongs to the guardian standing behind you and to the will of the gods.»
His father was silent as his chair rocked back and forth and his eyes remembered the past. Arthur could tell that there was more in his father’s life than he knew that could contribute to his motives.
«I was nobody,» his father said. “But before that, I was the son of a powerful awakener, dema-rank, who earned everyone’s admiration. It was worse than being a nobody because there are no expectations when you’re a nobody.»
«As much as I’m interested in what made you this way, I have more urgent things to attend to,» Arthur said with a frown. «Why did you plan to steal my powers?»
«I’ve never told my story to anyone, so if you want answers, you should listen, my dear Art,» smiled his father. Arthur’s face was far from amused, but he no longer interrupted him as the middle-aged man began to tell his story.
***
“There is a difference between a strong man and a weak one,” said his strict father, “between a strong man and a weak one. The difference is who survives to the end. There is no point in strength if you don’t survive.»
His father was a man who worshiped nothing less than strength. This was the reason why he was a powerful awakener respected by all. However, his son turned out to be far from strong, a weakling who breaks down in the face of adversity.
Seref was a kind child, he inherited this trait from his mother, his father’s second wife. Unfortunately, however, his father and half-siblings turned this kindness into weakness, and perhaps rightly so.
During his first dungeon dive, Seref ran away from a monster. It wasn’t because he lost, but because he won and couldn’t bring himself to kill the monster. Upon learning of this incident, the father lost hope in his son, and Seref’s life became much harder.
His father ran a guild that defended part of the city, and one day, when Seref was walking around the city, there was an escape from the dungeon. The most terrible monsters seemed to kill everything in their path, but they were held back by a single person.
Armed with his war hammer and heavy armor, his father looked like a god of ancient times. Seref was among the people his father saved and he saw the worship in their eyes.
From that day on, his father became known as the Savior, and Seref’s expectations became heavier. In the end, however, the expectations were not placed on his father, but on Seref himself.
«I want to be worshiped,» the teenager said to his father, who looked at him with disdain. «I want to be a savior.»
“This is a stupid reason to pursue power and do it. You have to kill both monsters and people.»
«I will do it.»
His determination was unwavering, and perhaps that is why his father saw him in a new light. After that day, his father trained him in the same way as his other brothers, but Seref never managed to kill the monster or the man.
As the days passed, his father trained him less frequently, and Seref saw the disappointment in his eyes. However, Seref believed that everything would change once his heart hardened, and as he wished, this came at a heavy cost.
«Your weakness failed us one last time,» said his father, surrounded by the armored corpses that attacked Seref and his mother. «Leave this earth and never return, Arthur.»
His inability to protect his kind and loving mother cost Seref his father and he was excommunicated from his family. After that, he changed his name to Seref and left the city, traveling to a distant land famous for its artifacts.
The loss he experienced at that time can only be made up for by a single desire to become stronger. The guilt that tore at his heart can only be quenched by countless books of archaic knowledge of true powers.
It was then that he stumbled upon the courts and the inheritance. Seref wanted to be worshipped and he wanted absolute power. His inability to save his mother made him desperate to save something. That is why he aspired to be a vessel and did everything to succeed.
After losing his youth to obsessions and dirt-digging, Seref finally met one of the gods. It was none other than the god of artifacts and knowledge, but he had no intention of making Seref stronger.
However, the Guardian Scientist showed Seref another way. His father failed to make him stronger, and that was the only thing he wanted. So when the guardian told him why he was chosen, Seref wept.
***
«I was chosen as the father of the most powerful being,» Seref said with a sad smile. “I wanted strength to survive, but instead I was given glory. I will forever be remembered as the reason for the survival of this world.»
Arthur stared at his father, who seemed to end his story with the last sentence of his sincere wish. He hated to listen. It was not a man, but a ghost from the past, trying to fill its gaping holes with whatever it could find.
His father had his own reasons to seek strength, but everything after that was done to satisfy his dreams of honor and caring environment, which his father did not give him.
However, what made Arthur really sick was one detail. It was his name. His father had a previous name and that was also Arthur. However, after it was abandoned, he abandoned it and gave it to his son.
“I have your name,” Arthur muttered, frowning, but his father did not answer. «You disgust me.»
His hatred was irresistible. Arthur felt like he wanted to tear his father apart for treating him this way. He was not given anything that belonged to him, and everything he had so far was for the sake of his father.
«I wish I had what you have,» said the father. “My father never gave me anything, not even a name. My mother gave me a name. My father never encouraged me to train, let alone dedicate my life to making me strong. it wasn’t enough for you to listen.»
«I only have one life and you want it to be yours.»
Level Up Legacy
Upcoming Chapters:
Chapter 630: In the CloudsED Chapter 629: Fallen KnightChapter 628: Against All OddsChapter 627: Dungeon EscapeED Chapter 626: I Hate DestinyChapter 625: Imp DeathChapter 624: Never Break ED Chapter 623: Bring DoomChapter 622 : War Between the WorldsChapter 621: The Most Important Chapter 620: My Own PlanChapter 619: Paralyzing ConfidenceED Chapter 618: Self WillChapter 617: Iron WillChapter 616: Time to DieChapter 615: Justified MeansChapter 614: Denaturing SharpnessChapter 613: IntruderChapter 612: Danger SeductionChapter 611: Materialized Concept Chapter 610 : Child Without TearsED Chapter 609: Timeless InsigniaChapter 608: Sacrifice for PeaceChapter 607: Witch’s TaleChapter 606: Judgment for KindnessChapter 605: Alchemist and WitchChapter 604: IllusionChapter 603: Abandoned FreyaChapter 602: ChainsChapter 601: ProudED Chapter 600: All-Knowing VesselChapter 599: Nonsense Chapter 598: DestinyChapter 597: Spiritual contractED Chapter 596: The Illusion of PeaceChapter 595: A «Helpful» FriendChapter 594: God of SightChapter 593: The Falling MountainChapter 592: Flesh and BonesChapter 591: Refusing to Break Chapter 590: Struggle for FriendshipChapter 589: Armament of NothingED Chapter 588: Blood PillarChapter 587: Underground Arrays Chapter 586: Moonlight CrossbowChapter 585: Not AssassinsChapter 583: Tough PlaceED Chapter 582: Race Against TimeED Chapter 581: Rune GuardsChapter 580: Hope is Dead Chapter 579: Inherited NameChapter 578: 2049Chapter 577: Painful MemoryChapter 576: Ice IllusionChapter 575: Berliot’s HatredED Chapter 574: The Selfish Good ManChapter 573: Connection DisruptionChapter 572: The PuppeteerChapter 571: What He FearedChapter 570: Petty ThievesChapter 569: No conditions Chapter 568: Vetance of Knowledge 567: Reverse Family Glava 566: Her sincerity 565: Kingdom Berido -ecado 564: Ghost Government 563: My dear student 562: The hated friend 561: Fear of losing 560: their gratitude to 559: Nothing but truth 558: 558: Ivy NewsChapter 557: When Hard Times ComeChapter 556: City of RuneChapter 555: Pure DestructionChapter 554: ClimbingChapter 553: Weak PresenceChapter 552: Too MuchChapter 551: RebellionChapter 550: SchemeChapter 549: Being a Store OwnerChapter 548: Hidden Ruins in RunerChapter 547: Those Two WordsChapter 546: A Burning CandleChapter 545: A Face in MemoriesChapter 544: Leave and Follow MeChapter 543: Changing EmotionsChapter 542: The Decision to LeaveChapter 541: Path of SufferingChapter 540: The First LieChapter 539: Mysterious sentenceChapter 538: Return to EarthChapter 537: Rise of the CreatorChapter 536: Another FutureChapter 535: Breaking FreeChapter 534: Impossible ChoiceChapter 533: AwayChapter 532: Chains of OrderChapter 531: Time to ReturnChapter 530: Into the VillainChapter 529: Perseverance
- Next Chapter 580: Hope is dead
- Previous Chapter 578: 2049
Choose your expressions when writing a comment. Insulting users — ban. With complaints about the user in Menu -> Support.
Inheritance — SwiftBook
A class can inherit methods, properties, and other characteristics of another class. When one class inherits from another class, then the inheriting class is called is a subclass of , whose class is inherited — by a superclass of . Inheritance is the fundamental behavior that separates classes from other Swift types.
Classes in Swift can call or access methods, properties, indexes belonging to their superclasses and can provide their own rewrites of these methods, properties, indexes to enhance or modify their behavior.
Classes can also add property observers to inherited properties in order to be aware when a property value changes. Property observers can be added to any property, whether they were originally defined as stored or computed properties.
Any class that does not inherit anything from another class is called the base class .
Note
Classes in Swift do not inherit anything from a generic base class. Classes that do not have a super class (parent class) are called base classes, which you can use to build other classes.
The example below defines the Vehicle class. This base class defines a stored property, currentSpeed, with an initial value of 0.0 (inferred type Double). The value of the currentSpeed property is used by the computed, non-editable description property of type String to create a description of the vehicle (an instance of Vehicle).
The Vehicle class also defines the makeNoise method. This method doesn’t actually do anything to the base instance of the Vehicle class, but will be configured by a subclass of the Vehicle class a bit later:
class Vehicle { var currentSpeed = 0.0 var description: String { return "moving at \(currentSpeed) miles per hour" } func makeNoise() { // do nothing, since not every transport is noisy } }
You create a new instance of the Vehicle class using the initializer syntax, which is written as TypeName followed by empty parentheses:
let someVehicle = Vehicle()
After creating a new instance of the Vehicle class, you can access its description property to display a description of the vehicle’s current speed:
print("Vehicle: \(someVehicle.description)") //Vehicle: moving at 0.0 mph
The Vehicle class defines the normal characteristics for a normal vehicle, but we can’t use them specifically. To make the class more useful, you need to enhance it to describe more specific modes of transport.
Inheritance is the act of creating a new class from an existing class (the base class). A subclass inherits characteristics from an existing class, which can then be enhanced. You can also add new characteristics to a subclass.
To indicate that a subclass has a superclass, simply write the subclass name followed by the superclass name and separate them with a colon:
class SomeSubclass: SomeSuperclass { // subclass definition is done here }
The above example defines a Bicycle subclass with a Vehicle superclass:
class Bicycle: Vehicle { var hasBasket = false }
The new Bicycle class automatically collects all Vehicle characteristics, such as the currentSpeed and description properties and the makeNoise() method.
In addition to the characteristics it inherits, the Bicycle class defines its new stored property hasBasket, with a default value of false (the property type is inferred as Bool).
By default, any new Bicycle instance you create will not have a basket (hasBasket = false). You can set hasBasket to true for a particular Bicycle instance after it has been created:
let bicycle = Bicycle() bicycle.hasBasket = true
You can also modify the Bicycle instance’s inherited currentSpeed property and query its description property:
bicycle.currentSpeed = 15.0 print("Bicycle: \(bicycle.description)") //Bicycle: moving at 15.0 mph
Subclasses can create subclasses themselves. In the following example, the Bicycle class creates a subclass for a two-seater bike known as a «tandem»:
class Tandem: Bicycle { var currentNumberOfPassengers = 0 }
The Tandem class inherits all properties and methods from Bicycle, which in turn inherits all properties and methods from Vehicle. The Tandem subclass also adds a new stored property, currentNumberOfPassengers, which defaults to 0.
If you instantiate Tandem, you can work with any of its new and inherited properties. The description property, which is a read-only property, it inherits from Vehicle:
let tandem = Tandem() tandem.hasBasket = true tandem.currentNumberOfPassengers = 2 tandem.currentSpeed = 22.0 print("Tandem: \(tandem.description)") // Tandem: moving at 22.0 mph
Subclasses can provide their own implementations of instance methods, class methods, instance properties, class properties, or an index that would otherwise inherit from the superclass. This is known as override .
To override characteristics that will be inherited anyway, you attribute the override keyword to the override definition. By doing so, you show that you intend to redefine, and that it will not be done by mistake. Rewriting by accident can cause unexpected behavior, and any override without the override keyword will be considered a compile-time error.
The override keyword also tells the Swift compiler to check that you are overriding the superclass of the class (or one of its parameters) that contains the definition you want to override. This check ensures that your override is correct.
Accessing superclass methods, properties, indexes
When you override a method, property, index for a subclass, it is sometimes useful to use the existing implementation of the superclass as part of your override. For example, you can improve the behavior of an existing implementation or store the changed value in an existing inherited variable.
Where appropriate, you can access a method, property, version index of the superclass if you use the super: 9 prefix0003
- An overridden someMethod can call the superclass version of someMethod by writing super.someMethod() inside the method implementation override.
- An overridden property someProperty can access a property of the superclass version of someProperty as super.
someProperty inside a getter or setter implementation override.
- An overridden index for someIndex can access the superclass version of the same index as super[someIndex] from within the index implementation override.
Overriding methods
You can override an inherited instance or class method to provide a custom or alternative version of the method implementation in a subclass.
The following example defines a new Train subclass of the Vehicle class that overrides the makeNoise() method that Train inherits from Vehicle:
class Train: Vehicle { override func makeNoise() { print("Choo-choo") } }
If you create a new instance of the Train class and call its makeNoise() method, you will see that the subclass version of Train is called like this:0003
let train = Train() train.makeNoise() // Output "Choo-choo"
Overriding properties
You can override inherited properties of a class or instance to set your own getter and setter for that property, or add a property observer to observe the overridden property when the underlying property value changes .
Property getter and setter overrides
You can provide a custom getter (and setter if needed) to override any inherited property, whether the property was defined in the source itself, as a storage property, or as a computed property. The subclass does not know whether the inherited property is stored or computed, all it knows is the name of the property and its type. You must always state both the name and type of the property you are overriding so that the compiler can check that the superclass has the property being overridden.
You can expose an inherited read-only property as a readable and editable property by writing both a getter and a setter in your overridden subclass property. However, you cannot do the opposite, that is, make the property editable and readable a read-only property.
Note
If you provide a setter as part of a property override, you must also provide a getter for that override. If you don’t want to change the value of an inherited property inside an overridden getter, then you can simply pass through the inherited value by returning super. someProperty from the getter, where someProperty is the name of the parameter you are overriding.
The following example defines a Car class, which is a subclass of Vehicle. The Car class provides a new gear storage property with a default value of 1. The Car class also overrides the description property it inherits from Vehicle to provide its own description that includes the current gear:
class Car: Vehicle { vargear = 1 override var description: String { return super.description + "in gear \(gear)" } }
The description property override starts with super.description, which returns the description property of the Vehicle class. The Car class version of the description property adds additional text to the end of the description of the current description property.
If you create an instance of the Car class and set the gear, currentSpeed properties, you will see that its description property returns a new description of the Car class:
let car = Car() car.currentSpeed = 25.0 car gear = 3 print("Car: \(car.description)") // Prints "Car: moving at 25.0 mph in gear 3"
Overriding property observers
You can use property overriding to add observers to an inherited property. This allows you to be notified when the value of an inherited property changes, regardless of how the property was originally implemented. For more information about property observers, see the chapter Property Observers.
Note
You cannot add property observers to an inherited constant property or to an inherited read-only computed property. The value of these properties cannot be changed, so there is no point in writing willSet, didSet as part of their implementation.
Also note that you cannot provide the same property with both an overridden observer and an overridden setter. If you want to watch the value of a property change, and you are willing to provide a custom setter for that property, then you can simply watch some value change from the setter.
In the following example, we will define a new class, AutomaticCar, which is a subclass of Car. The AutomaticCar class represents a car with an automatic transmission that automatically changes gears depending on the current speed:
class AutomaticCar: Car { override var currentSpeed: Double { didSet { gear = Int(currentSpeed / 10.0) + 1 } } }
Wherever you set the currentSpeed property of an AutomaticCar instance, the didSet property observer sets the instance’s gear property to the appropriate gear value depending on the speed. To be precise, the property observer selects the transfer as a value equal to currentSpeed divided by 10 and rounded down and chooses the nearest integer + 1. If the speed is 10.0, then the transfer is 2, if the speed is 35.0, then the transfer is 4:
let automatic = AutomaticCar()
automatic.currentSpeed = 35.0
print("Automatic machine: \(automatic.description)")
//Outputs "Automatic car: moving at 35.![]()