[swift-evolution] [Pitch] Percentage Type

Jonathan Hull jhull at gbis.com
Wed Jan 17 01:47:47 CST 2018

If you look at the implementation I provided, it allows for percentages higher than 100% (and has an easy way to clip them or map them to an arbitrary range).

> On Jan 16, 2018, at 11:39 AM, Dave DeLong via swift-evolution <swift-evolution at swift.org> wrote:
>> On Jan 16, 2018, at 9:56 AM, Jon Gilbert via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> No to this pitch, because a percentage can be higher than 100%.
> ☝️ One need only look in Activity Monitor to see this in action.
>> Use NumberFormatter to display a number as a percentage. https://developer.apple.com/documentation/foundation/numberformatter <https://developer.apple.com/documentation/foundation/numberformatter>
> I agree 1000% 😉 
>> Or you could make an NSNumber subclass if you want to enforce an arbitrary rule upon numbers.
> In theory you can; in practice you can’t. Subclassing things like NSNumber is fraught with undocumented peril.
> Dave
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20180116/2b13ece7/attachment.html>

More information about the swift-evolution mailing list