0 votes
in Swift by
Which method is used to check for prefix in Swift?

A

hasPrefix

B

isPrefix

C

isPart

D

has

1 Answer

0 votes
by

Answer: A

Reason:  To check whether a string starts with another string we can use hasPrefix and to check whether a string ends with another string, hasSuffix can be used. Example for prefix: "attitude".hasPrefix("at") // true Example for suffix: "Swift Programming".hasSuffix("ing") // true

Related questions

0 votes
asked Nov 6, 2022 in Swift by rajeshsharma
0 votes
asked Nov 6, 2022 in Swift by rajeshsharma
...