Question: I have an enum for tagged values (this is from a toy Scheme interpreter project), like this:

```
enum Value {
  case int(Int)
  case float(Float)
  case bool(Bool)
  ...
}

```

I wrote an initializer for it:

```
init?(value:Any) {
  switch v {
    case let v as Int: self = .int(v)
    case let v as Float: self = .float(v)
    case let v as Bool: self = .bool(v)
    ...
    default: return nil
  }
}

```

With that, calling `Value(3)` returns an (optional) Value.int(3), as expected. Bool's and the other types work too.

But `Value(0.1)` hits the default case and returns `nil`.

(Edited for correctness and recommended style. Thank you everyone for pointing those issues out.)

Answer: 
The default inferred type for floating point constants is `Double`, not `Float`. It's defined by the swift standard library here: <https://developer.apple.com/reference/swift/floatliteraltype> using the compiler-known `FloatLiteralType` typealias.
Btw, it looks like you want to be able to init your `Value` type with literals, so you may try conforming your type to `ExpressibleBy*` protocols.

Like:

```
extension Value: ExpressibleByIntegerLiteral {
    init(integerLiteral value: Int) {
        self = .int(value)
    }
}

let v1: Value = 42 // v1 == Value.int(42)   

extension Value: ExpressibleByBooleanLiteral {
    init(booleanLiteral value: Bool) {
        self = .bool(value)
    }
}

let v2: Value = true // v2 == Value.bool(true)

extension Value: ExpressibleByFloatLiteral {
    init(floatLiteral value: Float) {
        self = .float(value)
    }
}

let v3: Value = 0.5 // v3 == Value.float(0.5)

```