zoukankan      html  css  js  c++  java
  • Io_Language

     Object ancestor := method (
         prototype := self proto
         if (prototype != Obejct,
             writeln ("Slots of ",
                      prototype type,
                      "
    ------------------"
             )
             prototype slotNames foreach (slotName,
                                          writeln (slotName)
             )
             writeln prototype ancestors
         )
     )
     unless := method (
         (
                 call sender doMessage (
                         call message argAt(0)
                 )
         )
         ifFalse (
                 call sender doMessage (
                         call message argAt(1)
                 )
         )
         ifTrue (
                 call sender doMessage (
                         call message argAt(2)
                 )
         )
     )
    

     Animals.io

        Object ancestors := method (
            prototype := self proto
            if (prototype != Object,
                writeln ("Slots of ", 
                    prototype type,
                    "
    ----------------"
                )
                prototype slotNames foreach (
                    slotName, 
                    writeln (sloteName)
                )
                writeln prototype ancestors
            )
        )
        
        Animal := Object clone
        Animal speak := method (
            "ambiguous animal noise" println
        )
        Duck := Animal clone
        Duck speak := method (
            "quack" println
        )
        Duck walk := method (
            "waddle" println
        )
        disco := Duck clone
        disco ancestors
                

     

  • 相关阅读:
    SAMBA服务初学练习
    NFS与AutoNFS实例
    NTP服务简介
    DHCP服务简单搭建步骤
    HBase文档操作--练习篇
    Hadoop体系结构管理
    HBase表结构设计--练习篇
    HBase备份恢复练习
    MongoDB管理练习
    24_BlockingQueue接口
  • 原文地址:https://www.cnblogs.com/thoupin/p/3691445.html
Copyright © 2011-2022 走看看