3

Ruby Motionには、次のようにフォーマットされた多くのビルド済み関数が付属しています。

def tableView(tv, numberOfRowsInSection:section)
  # blah
end

私はこのように自分の機能を削除したいと思います。考案された例:

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

このコードはrubymotion1.0ではコンパイルされません...これを行う方法はありますか?もしそうなら、どのように?

4

2 に答える 2

7

カンマがありません:

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

結果:

(main)>> Timeser.new.multiplyNumber(2, byNumber: 3)
=> 6
于 2012-05-06T19:20:34.353 に答える
0
class Foo
  def initWithThingOne(one, andThingTwo: two)
    puts one
    puts two
  end
end

Foo.new.initWithThingOne "1", andThingTwo: "2"
=>
1
2
于 2012-05-06T18:55:29.390 に答える