行銷筆記

23. Writing Methods_Your First iOS and SwiftUI App

Reference: Method

Imagine you want to add a method that has no input, in other words, no parameters, but it does have an output, in other words, a return value. To do this, you’d simply add a block of code that looks like this before the final curly brace of your class.

Screen Shot 2020-01-26 at 3.07.20 AM
When you enter an open and closed parenthesis,  it means it has no input, or no parameters. Then you put a dash and a greater than sign, which looks kinda like an arrow to me. Then you indicate the type of object that you will return as the output of your method, like Int, Double, or Bool. Inside the curly braces, you put all of your code.

where you place the method doesn’t really matter.

0 comments on “23. Writing Methods_Your First iOS and SwiftUI App

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: