万年素人からHackerへの道

万年素人がHackerになれるまで殴り書きするぜ。

  • ・資産運用おすすめ
    10万円は1000円くらい利益
    資産運用ブログ アセマネ
    • ・寄付お願いします
      YENTEN:YYzNPzdsZWqr5THWAdMrKDj7GT8ietDc2W
      BitZenny:ZfpUbVya8MWQkjjGJMjA7P9pPkqaLnwPWH
      c0ban:8KG95GXdEquNpPW8xJAJf7nn5kbimQ5wj1
      Skycoin:KMqcn7x8REwwzMHPi9fV9fbNwdofYAWKRo

    Boo Language Advent Calendar 2012 18日目 Title:「Booで例外処理とか」

    URL: http://atnd.org/events/34622

    Booの公式はこちらです
    http://boo.codehaus.org/Part+14+-+Exceptions
    http://boo.codehaus.org/Exception+Handling

    ・ExceptionTest.boo

    import System
    
    class ExceptionTest (MonoBehaviour):
    
        def Start ():
            try:
                Debug.Log(1 / 0)
            except e as DivideByZeroException:
                print "Whoops"
            print "Doing more..."
    

    とUnityらしく書きました。

    Assets/Scripts/ExceptionTest.boo(7,25): BCE0055: Internal compiler error: Division by zero.

    実行時すると実行する前にこのエラーで怒られました。

    さらにこれも

    import System
    
    public class MyClass:
        def SomethingBad():
            Debug.Log(1 / 0)
    
    class ExceptionTest (MonoBehaviour):
    
        def Start ():
            try:
                s = MyClass()
                s.SomethingBad()
            ensure:
                print "This code will be executed, whether there is an error or not."
    

    実行する前にすでに怒られます・・。

    これだと書けないね。

    では次へ