コード例 #1
0
    // Use this for initialization
    void Start()
    {
        Dog           d      = new Dog();
        IOption <Dog> dogOpt = new Some <Dog> (d);

        //ok
        Dog dog = dogOpt.GetOrElse <Dog> (() => new Dog());

        //crash at this point. does it care about polymorphism? but it works on pure .net project
        Animal animal = dogOpt.GetOrElse <Animal> (() => new Cat());

        print("r2 -" + animal);
    }
コード例 #2
0
        public void GetOrElse_OptionIsSome_ValueReturned()
        {
            var option = new Some<string>("some value");

            var result = option.GetOrElse(() => "default value");

            Assert.AreEqual("some value", result);
        }