What is the most important for Frontend developers?

Frontend development is a crucial part of web development, and it has become increasingly important in recent years. The role of frontend developers has evolved to meet the ever-changing demands of…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Substring made easy in swift with the aid of subscript

This shows a custom way to substring a string, It is often called ‘slicing’.

Subscript

This is a keyword simply use to set and retrieve values by index without the need to separate methods for setting and retrieval. It is a shortcut for accessing the member elements of a collection, list, or sequence.

It follows this procedure

string[start, end]

where,

start: The starting index of the substring. The character at this index is included in the substring.

end: The terminating index of the substring. The character at this index is included in the substring.

The implementation goes as follow:

Usage:

Output:

Add a comment

Related posts:

Peaches for Hope Mission

This is a time unlike any I remember. The news brings a steady drip of bad to terrifying news and there’s no telling what tomorrow will bring. I’ve been fluctuating between dread, despair, and a…

Should we get rid of money?

The other day when we took the kids to a tour of a heritage centre, the guide elaborated how the town’s medieval market was only accessible to the upper class as others were not allowed to own money…