SwiftRandom - Random data generator for swift

30 views
Skip to first unread message

Demir B Yılmaz

unread,
Oct 12, 2015, 11:29:40 AM10/12/15
to Swift Language

Jeremy Pereira

unread,
Oct 13, 2015, 4:55:03 AM10/13/15
to Demir B Yılmaz, Swift Language
Your code for func random() -> Bool should really be


public static func random() -> Bool {
return Int.random(0, 1) == 0
}

Also, why the arbitrary range of 0 … 100? Where practical, you should use the full range of integral types (bit of a problem for Int on OS X which is 64 bit) or probably 0 ..< 1 for floating point types.

And I think you should omit any dependency on UIKit. As it stands, a OS X developer can’t use your code without hacking bits out.

> On 12 Oct 2015, at 12:55, Demir B Yılmaz <demirber...@gmail.com> wrote:
>
> https://github.com/thellimist/SwiftRandom
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Swift Language" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to swift-languag...@googlegroups.com.
> To post to this group, send email to swift-l...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/2e3ff222-bad1-43f8-a4f9-9055a810df1a%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages