Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
346 views
in Technique[技术] by (71.8m points)

Why is it that sometimes Swift requires explicitly indicating an argument and sometimes not?

I am trying to use the following library: https://github.com/peek-travel/swift-currency

One of the ways to use it is to do something like this to mean it is 5 dollars in USD:

USD(5.01)

I noticed that in one of my subviews, when I do this, I get the error of:

Compiling failed: missing argument label 'floatLiteral:' in call

Which I can fix by doing USD(floatLiteral: 5), which means the same thing.

Why is it that in some cases in my code I can do USD(5) without an error, and in others I have to explicitly state the argument?

Documentation for USD from API reference is here: https://peek-travel.github.io/swift-currency/Structs/USD.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...