Coder Social home page Coder Social logo

Comments (2)

SapiensAnatis avatar SapiensAnatis commented on August 28, 2024 1

That's fair enough. I eventually came up with what I consider to be an acceptable workaround - I created my own implementation of IPick which takes in a single value and always returns that value. Then I just used a factory method to return either that in the 1-element case, or a normal picker in every other case.

from fluent-random-picker.

ndsvw avatar ndsvw commented on August 28, 2024

Hello, it was implemented like this for 2/3 reasons:

  1. consistency: The fluent syntax does not allow something like Out.Of().Value(3).Pick(). It compiles only when calling AndValue() at least once.
    • In your case, it is an unexpected behavior, but in other cases, it could be useful, because maybe, someone has accidentally passed only 1 value.
    • Especially when additionally specifying weights (e.g. "please pick form the following values: letter z with weight 37; that's it"), from the library point of view, it looks more like it received wrong input.

To be honest: I don't know what the best solution is (status you, your suggestion, allowing to configure the behavior) and I can't promise you to change the logic.

from fluent-random-picker.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.