Swift function return value

Source: Internet
Author: User

Definition and invocation of functions

Func begins with the type returned as a prefix,->

The result of the add output is 11.

Function parameters can also have multiple parameters, written in parentheses separated by commas.

1 func Introduce (name: stringIntstring2{ 3     return " \ (name), I ' m \ (age)-   year-old now. " 4 }5 introduce ("Zing",)

No parameter function

1 func HelloWorld () 2 {3     return " Hello World " 4 }5 print (HelloWorld ())

Multiple return value functions

1Func operation (Pending:int ...)(Add:int,ride:int)2 {3     varAD =0, RI =14      forAinchAdd5     {6ad+=a7     }8      forRinchRide9     {Tenri*=R One     } A     return(Ad,ri) - } -Let result = Operation (5,Ten,Ten) thePrint"add \ (result.add), multiply \ (result.ride)")

Swift function return value

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.