mksc source (0.0.5) | 2010-01-11 22:11 |
mksc win32-binary (0.0.5) | 2010-01-11 22:12 |
if <条件式> then 内部ブロック [ elseif <条件式> then 内部ブロック ]* # 0 回以上記載 [ else 内部ブロック ]? # 0もしくは1回記載 end
if x == 10 then Console << "x == " << x << "\n" elseif x < 10 then Console << "x < " << 10 << "\n" else Console << "x > " << 10 << "\n" end
Console.println( "error" ) if x < 0 return -1 if x < 0 raise MyException.new() if x < 0 break if x > 5 continue if x % 2 == 0
# 前置条件型 while <条件式> 内部ブロック end # 後置条件型 do 内部ブロック end while 条件式
# 前置条件型 while x != 10 x = x + 1 end while x != 10 if x == 5 then break # breakで繰り返し内部ブロックを抜ける end x = x + 1 end while x != 10 x = x + 1 if x == 5 then continue # continueで、繰り返し構造の先頭(条件評価)から処理をやり直します。 end y = y + 1 end # 後置条件型 do x = x + 1 end while x != 10
do x = x + 1 if x == 5 then continue # continueで、繰り返し構造の先頭(内部ブロックの先頭)から処理をやり直します。 end y = y + 1 end while x != 10
def method1( ) end x = @method1 def class.method2( ) end x = @@method2
class C0 def class.method() end def instance_method( ) end end p = C0.new() x = p.@instance_method y = C0.@@method
def method( ) end x = @method x.invoke( ) # method( ) の呼び出し x( ) # これも method の呼び出し def method_2( a, b, c ) return a + b + c end x = @method_2 Console << x.invoke( 1, 2, 3 ) << "\n" # method_2( 1, 2, 3 )の呼び出し Console << x( 1, 2, 3 ) << "\n" # これもmethod_2( 1, 2, 3 )の呼び出し
x = block if mode = 1 then return method_1( ) elseif mode == 2 then return method_2( ) end end
y = |a, b, c| block if mode = 1 then Console << a elseif mode == 2 then Console << b else Console << c end end
c = 10 y = |a,b| block return a + b + c end z = |a,b,c| block return a + b + c + owner.c end
x = block if mode = 1 then method_1( ) elseif mode == 2 then method_2( ) end end x( ) # x に代入されたブロックを呼び出す x.invoke( ) y = |a, b, c| block if mode = 1 then Console << a elseif mode == 2 then Console << b else Console << c end end y( 1, 2, 3 ) # ブロック引数として、1, 2, 3 を渡し、ブロックを呼び出す。 y.invoke( 1, 2, 3 )
|a, b, c| block if mode = 1 then Console << a elseif mode == 2 then Console << b else Console << c end.invoke( 1, 2, 3 )
a = 1 b = 2 x = { a + b + c } y = | a, b | { a + b + owner.a + owner.b }
a = 1 b = 2 x = { a + b + c } y = | a, b | { a + b + owner.a + owner.b } x() y(3,4)
[PageInfo]
LastUpdate: 2010-01-15 00:24:06, ModifiedBy: mikenekodx
[Permissions]
view:all, edit:members, delete/config:doc editors