, . , , , , . , .
-, try
- Swift. . . , , try
. try
. :
class X {
func x() throws -> X {
return self
}
}
let y = try X().x().x()
try
, . , , x()
-. " ", try
.
. :
let resul1 = myClass.fun1() // error: ambiguous use of 'fun1()'
Swift . Any or it could be
Int`, .
( ):
let result1: Int = myClass.fun1()
, ( no ?
):
let x : Any = try myClass.fun1()
( )
let x : Any = try? myClass.fun1()
Int
? try?
( Any). , Swift , Int?
Any
Any?
Any
. Swift Any
( Any?
). Any
. . , , Any
- , .
, print
? print
Any
, let x: Any =...
, let x =...
.
, , :
- T T?
- T Any
- T?
- Any? ( Any??, Any???, Any???? ..)
- ? (Any??, Any??? ..) Any
, / Any/Any? try?
( , ), .
, .