Skip to content

Instantly share code, notes, and snippets.

@arriqaaq
Last active January 26, 2023 07:25
Show Gist options
  • Save arriqaaq/4bf54e4565914ef2ace494caffa3975d to your computer and use it in GitHub Desktop.
Save arriqaaq/4bf54e4565914ef2ace494caffa3975d to your computer and use it in GitHub Desktop.
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