To declare a float array in Swift, you can use array literal notation or the Array constructor.
In this example,
floatArray
with predefined values using array literal notation.let floatArray: [Float] = [1.2, 3.4, 5.6]
print("Float Array:", floatArray)
Float Array: [1.2, 3.4, 5.6]
In this example,
emptyFloatArray
using the Array constructor without any elements.let emptyFloatArray = [Float]()
print("Empty Float Array:", emptyFloatArray)
Empty Float Array: []
In this tutorial, we learned How to Declare a Float Array in Swift language with well detailed examples.