4D v18

formula.apply( )

ホーム

 
4D v18
formula.apply( )

formula.apply( )  


 

説明  

formula.apply( ) メソッドは、フォーミュラオブジェクトを適用している対象に対して実行し、その結果の値を返します。フォーミュラオブジェクトはFormula あるいはFormula from string コマンドで作成されたものを使用可能です。

thisObj 引数には、フォーミュラ内でThis として使用されるオブジェクトへの参照を渡すことができます。

任意のformulaParams 引数を使用することで、フォーミュラ内で$1...$n の引数として使用されるコレクションを渡すこともできます。

formula.apply( )formula.call( ) に似ていますが、引数をコレクションとして渡すという点が異なることに注意して下さい。これは計算された結果を渡すのに有用です。

 $f:=Formula($1+$2+$3)
 
 $c:=New collection(10;20;30)
 $result:=$f.apply(Null;$c// 60 を返す

 C_OBJECT($calc;$feta;$robot)
 $robot:=New object("name";"Robot";"price";543;"quantity";2)
 $feta:=New object("name";"Feta";"price";12.5;"quantity";5)
 
 $calc:=Formula(This.total:=This.price*This.quantity)
 
 $calc.apply($feta// $feta={name:Feta,price:12.5,quantity:5,total:62.5}
 $calc.apply($robot// $robot={name:Robot,price:543,quantity:2,total:1086}



参照 

formula.call( )

 
プロパティ 

プロダクト: 4D
テーマ: フォーミュラ

This command can be run in preemptive processes

 
ページの目次 
 
履歴 

 
ARTICLE USAGE

ランゲージリファレンス ( 4D v18)