热门问题
时间线
聊天
视角

方法級聯調用

来自维基百科,自由的百科全书

Remove ads

方法級聯調用(Method cascading)是面向對象編程語言中對同一個對象調用其多個方法時的一種語法糖。特別適用於實現流暢接口[1]

例如在Dart語言中:

a..b()
 ..c();

等價於單獨調用:

a.b();
a.c();

Visual Basic允許對同一個對象調用任意多次的方法或屬性:[2]

With ExpressionThatReturnsAnObject
  .SomeFunction(42)
  .Property = value
End With

With..End With塊在Visual Basic中可以嵌套:

With ExpressionThatReturnsAnObject
  .SomeFunction(42)
  .Property = value
  With .SubObject
    .SubProperty = otherValue
    .AnotherMethod(42)
  End With
End With
Remove ads

參見

參考文獻

Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads