Casting and Brackets Swift

Both of these types of casting work with
Edit
(as written by Nate Cook, this is not a real type of Casting, the Swift type is executed with a keyword as. In the next call, I initialize Int64 with the Float parameter.)

anInt = Int64(aFloat)

anInt = (Int64)(aFloat)

First

    var anInt : Int64 = 0
    var aFloat : Float = 11.5

    anInt = Int64(aFloat)
    println(anInt) // this prints 11

Second

    var anInt : Int64 = 0
    var aFloat : Float = 11.5

    anInt = (Int64)(aFloat)
    println(anInt) // this prints 11

In the second example, the main difference is that there are parentheses around the Int64 type, but I did not find any information about this syntax in the documents.

The statement Int64(aFloat)is a typical initializer call that creates an Int64, passing Float as initialization parameters. Is it correct?

What is the meaning of brackets in (Int64)(aFloat)? For better readability or is there another meaning? Thanks

+4
2

, (, (((Int64)))). , (object as SomeClass).method()

+4

. , , (Int) , Int, Int Int.

+1

All Articles