My question is not related to flagged question as I want to call both the functions at once.
I am looking for a solution when I can call two functions in a single line.
Here's the playground code.
import UIKit
func aFunc(file:String = #file, line:Int = #line, funcname:String = #function) {
print("file: \(file)")
print("line: \(line)")
print("function: \(funcname)")
}
func bFunc(num:Int, thing:String) {
for i in 1...num {
print("\(thing)\n")
}
}
func cFunc() {
bFunc(num: 1, thing: "I Swift!")
aFunc()
}
cFunc()
Above code is working fine. And giving this as output.
I Swift!
file: TestFunctions.playground
line: 19
function: cFunc()
However, I have a necessity where I will need to call bFunc( )
and aFunc( )
together.
I don't want to do it like you can see in the playground code.
I want something like or more better ways :
func cFunc() {
bFunc(num: 1, thing: "I Swift!").aFunc()
}
So it will output like the playground code.
What should I do to achieve this?
The reason I want to do is that I have written a lot of code and now I just don't want to make changes to achieve this functionality.