News for hackers. Stuff that matters.
Re:How I Learned to Stop Worrying and Love the State Machine by bushin on Monday February 26, 2018 @09:24PM (#16470669)
Well, maybe someday Dotty will be a mainstream language...

    trait Weapon
    class Sword extends Weapon
    class Staff extends Weapon
    class Dagger extends Weapon
    trait Player {
      type T <: Weapon
    }
    class Wizard extends Player {
      type T  = Dagger | Staff
      var weapon: T = null
    }
    class Warrior extends Player {
      type T = Dagger | Sword
      var weapon: T = new Sword
    }
Re:How I Learned to Stop Worrying and Love the State Machine by icebraining on Tuesday February 27, 2018 @02:56AM (#16471780)
Python already is a mainstream language:

    class Weapon: pass
    class Sword(Weapon): pass
    class Staff(Weapon): pass
    class Dagger(Weapon): pass

    class Player:
        weapon: Weapon
    class Wizard(Player):
        weapon: Optional[Union[Dagger, Staff]] = None
    class Warrior(Player):
        weapon: Optional[Union[Dagger, Sword]] = Sword()
Re:How I Learned to Stop Worrying and Love the State Machine by icebraining on Tuesday February 27, 2018 @02:50AM (#16471757)

    class Wizard extends Player {
      type T  = Dagger | Staff
      var weapon: T = null
    }
The billion-dollar mistake in a new language? What a waste.
Re:How I Learned to Stop Worrying and Love the State Machine by boubiyeah on Tuesday February 27, 2018 @03:59AM (#16472055)
Yeah that freaking blows. They keep it for compatibility with java. It's not idiomatic code though, you would use an Option.