# declaring a simple generic class HoldLastOne # Last In, Only Out var _count as int var _what as Type? const _one as int = 1 def add(what as Type) _what = what _count = 1 assert _one == 1 get pop as Type assert _count _count = 0 return _what to Type # .warning. just use get count as int return _count class Test def main is shared i as int = 3 assert i==3 hi as HoldLastOne = HoldLastOne() assert hi.count==0 hi.add(7) assert hi.count==1 assert hi.pop==7 assert hi.count==0 hb as HoldLastOne = HoldLastOne() assert hb.count==0 hb.add(false) hb.add(true) assert hb.count==1 assert hb.pop assert hb.count==0