Last active
January 26, 2023 07:25
-
-
Save arriqaaq/4bf54e4565914ef2ace494caffa3975d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type carFactory struct {} | |
func (c carFactory) Create(carType string) Car { | |
if carType == "sports" { | |
return SportsCar{} | |
} else if carType == "suv" { | |
return SUV{} | |
} | |
return nil | |
} | |
myCarFactory := carFactory{} | |
myCar := myCarFactory.Create("sports") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment