Skip to main content

You need to use the susbstring function.

String substr = a.substring(a.length() - 4) 

syntax is wrong. no type before vars in Swift.

let a = "1234567890" let last4 = String(a.characters.suffix(4)) print(last4) 

works on Swift 3.0

You need to use the susbstring function.

String substr = a.substring(a.length() - 4) 
String substr = a.substring(a.length() - 4) 

syntax is wrong. no type before vars in Swift.

let a = "1234567890" let last4 = String(a.characters.suffix(4)) print(last4) 

works on Swift 3.0

Source Link
sparsh610
  • 1.6k
  • 4
  • 29
  • 72

You need to use the susbstring function.

String substr = a.substring(a.length() - 4)