2012-05-05 10 views
3

Rubyのモーションは次のようにフォーマットされている事前に構築された機能の多くが付属していRubyで構文的に類似のObjective-Cのような関数を作成します。 ;考案例:ルビーモーション手動で

このコードは、ruby motion 1.0でコンパイルされません。これを行う方法はありますか?もしそうなら、どうですか?

class Timeser 
    def multiplyNumber(one, byNumber:two) 
    one*two 
    end 
end 

結果:あなたはコンマ不足している

+4

をカンマがone' '後があるはず? – UIAdam

答えて

7

(main)>> Timeser.new.multiplyNumber(2, byNumber: 3) 
=> 6 
0
class Foo 
    def initWithThingOne(one, andThingTwo: two) 
    puts one 
    puts two 
    end 
end 

Foo.new.initWithThingOne "1", andThingTwo: "2" 
=> 
1 
2