Skip to content

RNG parameter intuitiveness #2

Open
@zmeyc

Description

@zmeyc

It's a bit confusing that Int.random(0, 100) can return 100 as well, ranges usually exclude the second value. Lot more confusing that Int.random(range: 0..<1) returns 0...1. And inclusive range (...) is not supported at all.

(lldb) p Int.random(range: 0..<1)
(Int) $R24 = 0
(lldb) p Int.random(range: 0..<1)
(Int) $R25 = 1

Also Double.random() has a default of 0.0...100.0 while usually 0..<1 would be expected. Would you like me to submit a PR to adjust these?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions