Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

index string swift

let string = "Hello, World!"
let index = string.index(string.startIndex, offsetBy: 3)

print(string[index]) // Prints "l"

// This can be done in one line too:
print(string[string.index(string.startIndex, offsetBy: 3)])
Comment

string index in swift

extension String {
    subscript(_ n: Int) -> Character {
        return self[self.index(self.startIndex, offsetBy: n)]
    }
}

let str = "Hello World"

print(str[0]) // H
print(str[4]) // o
print(str[6]) // w
Comment

PREVIOUS NEXT
Code Example
Swift :: most frequent element in array swift 
Swift :: custom tab bar swift ios 
Swift :: view controller modal fullscreen programmatically swift 5 
Swift :: swift 5 get current date 
Swift :: iOS & Swift - The Complete iOS App Development Bootcamp 
Swift :: activity indicator swiftui 
Swift :: swift edit constraint programmatically 
Swift :: swift 5 get app version 
Swift :: swift image 
Swift :: swift pretty print json 
Swift :: symfony swiftmailer 
Swift :: swiftui crop image 
Swift :: remove and element from array firebase swift 5 
Swift :: how to show notification icon on tabbar item swift 
Swift :: swift extension Array where type 
Swift :: view will appear 
Swift :: swift uilabel font bold 
Swift :: swift 
Swift :: Swift Use of Hash Function 
Swift :: Swift Change Value of a Variable 
Swift :: swift print struct name 
Swift :: command compileswift failed with a nonzero exit code 
Swift :: list header swiftui 
Swift :: Autoclosure Swift 
Swift :: Swift Nested Function with Return Values 
Swift :: Assign values to enum variables Swift 
Swift :: get links from string or html a tag swift 
Swift :: swiftUI parse json from url 
Swift :: meu eclipse não gera a implementação do mapstruct 
Ruby :: ruby string to date 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =