Home > Mobile >  Swift function for help
Swift function for help

Time:12-06

The second function why output

CodePudding user response:

Clear may need knowledge:
1. The function of "- & gt;" Said, there is a return value of functions;
2. Call returns a value function, if do not deal with the return value, can use "_" to deal with, so, the compiler will not report warning;

Problem description:
1. "printAndCount" function is a return value, and the return value is an Int type;
2. "printWithoutCounting" function is not return a value;
3. "printWithoutCounting function calls the" printAndCount "internal", and use "let _" receiving treatment (to avoid a compiler warning);
4. The function of print, call it either directly or indirectly invoked, will print, all will print "hello, world";

The hope can help topic main,

CodePudding user response:

The second function is not the first function called? Just ignore the return value, nothing special
  •  Tags:  
  • iOS
  • Related