Created
December 30, 2020 05:18
-
-
Save ridhoperdana/9a2ebd3ca8c28997df9ae8afe19b30b3 to your computer and use it in GitHub Desktop.
example of single responsibility principle
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
) | |
func printEngineerName(names []string) { | |
for index, engineer := range names { | |
fmt.Printf("Some string at index %v with value %v", index, engineer) | |
} | |
} | |
func addNewEngineer(currentEngineer []string, newEngineer string) (updatedEngineers []string) { | |
updatedEngineers = append(currentEngineer, newEngineer) | |
return updatedEngineers | |
} | |
func main() { | |
engineers := []string{"John", "Doe", "Budi"} | |
engineers = addNewEngineer(engineers, "Agus") | |
printEngineerName(engineers) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment