Search results for

[tags:wwdc20-10037]

1 result found

Post

Replies

Boosts

Views

Activity

Can't get going on Numerics
Hi. I'm just trying to get some basic examples going, but no luck so far. The only function example I can find, func logit<NumberType: Real>(_ p: NumberType) -> NumberType { log(p) - log(onePlus: -p) } print(logit(12.456)) gets me a Cannot convert return expression of type 'Float' to return type 'NumberType' message from Xcode 12 beta on macOS 10.15.5. (It gives various suggestions, all of which don't help or lead me in the right direction.) This other attempt seems (* to me) like it should work: func testPow<T: Real>(_ x: T, toThe y: T) -> T { pow(x, y) } print(testPow(10.0, toThe: 12.3456)) but I get Type of expression is ambiguous without more context. I can't image what the missing contextual info might be here. (Both examples import both Foundation and Numerics.) Thanks for any help! Jeff
1
0
385
Jun ’20