String explained

This commit is contained in:
Mert Gör ☭ 2024-03-18 16:30:49 +03:00
parent 0418380fd2
commit d1fbf4865b
Signed by: hwpplayer1
GPG Key ID: 03E547D043AB6C8F
2 changed files with 28 additions and 0 deletions

View File

@ -50,6 +50,7 @@ import (
"golesson/maps"
"golesson/pointers"
"golesson/slices"
"golesson/string_functions"
"golesson/structs"
"golesson/variables"
"time"
@ -125,4 +126,5 @@ func main() {
interfaces.Demo3()
error_handling.Demo2()
fmt.Println(error_handling.GuessIt2(102))
string_functions.Demo1()
}

26
string_functions/demo1.go Normal file
View File

@ -0,0 +1,26 @@
package string_functions
//alias
import (
"fmt"
s "strings"
)
// case sensitive
// ascii
func Demo1() {
name := "Engin"
fmt.Println(s.Count(name, "g"))
fmt.Println(s.Contains(name, "g"))
fmt.Println(s.Index(name, "g"))
result := s.Index(name, "E")
if result != -1{
fmt.Println("E letter exists")
}else{
fmt.Println("E letter does not exist")
}
fmt.Println(s.ToLower(name))
fmt.Println(s.ToUpper(name))
}