I have code that does not compile:
func find( n : String, m: Int)
{
num = m
name = n
}
var name : String = "A"
var num : Int = 1
find( n: "1", m: 1)
print( name)
and he behaves as expected. But friends, please tell me why the following code snippet works. The variable is namealso defined after the function, but does it work this time?
func find( n : String, m: Int)
{
name = n
}
var name : String = "A"
find( n: "1", m: 1)
print( name)
What is wrong with global variable definitions?
source
share