Swift – Multiple Statements in a Single Line

To write multiple statements in a single line in Swift program, separate statements with a semi-colon.

Ending a statement with semi-colon is optional in Swift. But, if we would like to write multiple statements in a single line, we can make use of semi-colon.

Example

In the following program, we will write multiple statements in a single line by separating the statements with a semi-colon.

main.swift

Swift - Multiple Statements in a Single Line

Conclusion

In this Swift Tutorial, we learned how to write multiple statements in a single line in a Swift program.