4D v19

collection.extract( )

ホーム

 
4D v19
collection.extract( )

collection.extract( )  


 

説明  

collection.extract( ) ファンクションは元のオブジェクトのコレクションから、propertyPath 引数で指定したプロパティの値を格納した新しいコレクションを作成し、返します。

注: このコマンドは元のコレクションは変更しません。

返されたコレクションの中身は、targetPath 引数によります:

  • targetPath 引数が省略された場合、collection.extract( ) は元のコレクションのpropertyPath のパスの値で新しいコレクションを作成します。
    デフォルトで、propertyPath のパスの要素がnull あるいは undefined であった場合には、返されるコレクションには含まれません。option 引数にck keep null 定数を渡すことで、これらの値は返されるコレクションにnull 要素として含まれます。
  • 一つあるいは複数のtargetPath 引数が渡された場合、collection.extract( )propertyPath のプロパティを持った新しいコレクションを作成し、そのコレクションの各要素はtargetPath で指定したプロパティと対応するpropertyPath のプロパティを持つオブジェクトとなります。Null値はそのまま保持されます(このシンタックスではoption 引数は無視されます)。

 C_COLLECTION($c)
 $c:=New collection
 $c.push(New object("name";"Cleveland"))
 $c.push(New object("zip";5321))
 $c.push(New object("name";"Blountsville"))
 $c.push(42)
 $c2:=$c.extract("name") // $c2=[Cleveland,Blountsville]
 $c2:=$c.extract("name";ck keep null//$c2=[Cleveland,null,Blountsville,null]

 C_COLLECTION($c)
 $c:=New collection
 $c.push(New object("zc";35060))
 $c.push(New object("name";Null;"zc";35049))
 $c.push(New object("name";"Cleveland";"zc";35049))
 $c.push(New object("name";"Blountsville";"zc";35031))
 $c.push(New object("name";"Adger";"zc";35006))
 $c.push(New object("name";"Clanton";"zc";35046))
 $c.push(New object("name";"Clanton";"zc";35045))
 $c2:=$c.extract("name";"City") //$c2=[{City:null},{City:Cleveland},{City:Blountsville},{City:Adger},{City:Clanton},{City:Clanton}]
 $c2:=$c.extract("name";"City";"zc";"Zip") //$c2=[{Zip:35060},{City:null,Zip:35049},{City:Cleveland,Zip:35049},{City:Blountsville,Zip:35031},{City:Adger,Zip:35006},{City:Clanton,Zip:35046},{City:Clanton,Zip:35045}]



参照 

collection.map( )
entitySelection.extract( )

 
プロパティ 

プロダクト: 4D
テーマ: コレクション

This command can be run in preemptive processes

 
ページの目次 
 
履歴 

 
ARTICLE USAGE

ランゲージリファレンス ( 4D v19)
ランゲージリファレンス ( 4D v19.1)