Giter VIP home page Giter VIP logo

optional's People

Contributors

zoran-horvat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

optional's Issues

Operator == and != on abstract base class

I've already got an Option struct I implemented but I've been looking at yours to see if I could learn anything about good coding practice. It seems to me that the == operator won't work as expected if you've got two Option instances because the == operator is not defined on the abstract base class. The == operator is defined on Some and None but most of the time you'll have variables passed around as type Option so that seems to be the key scenario to support. I think you can do safe equality comparisons on the base class by comparing types (None!=Some) AND the Reduce value. Override the equality and inequality operators, and do IEquatable too. Then, to support IEquatable<Some> and IEquatable<None> in the derived classes, just have a single line like public bool Equals(Some<T> other) => (this as Option<T>).Equals(other as Option<T>);

At first I liked your approach of using an abstract base class to support both Some and None but given the value equality issues I wonder if a cleaner solution is just to use a single class for both.

Where is IOption defined?

I'm not sure all the code is included here. In your tests you reference IOption but I can't see that interface anywhere. Also when I download the whole repository into Visual Studio the test project isn't included automatically. I'm not that familiar with Git so maybe I'm doing it wrong. By the way, I love your Pluralsight presentations.

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.