ここは旧式の4DドキュメントWebサイトです。最新のアップデートされたドキュメントを読むには新サイトをご利用下さい→ developer.4d.com

ホーム

 
4D v19.8
collection.extract( )

collection.extract( ) 


 

collection.extract ( propertyPath {; targetPath}{; propertyPath2 ; targetPath2 ; ... ; propertyPathN ; targetPathN}{; option}) -> 戻り値 
引数   説明
propertyPath  テキスト in 新しいコレクションに取り出す値のオブジェクトプロパティパス
targetPath  テキスト in ターゲットのプロパティパスあるいはプロパティ名
option  倍長整数 in ck keep null: 返されるコレクションにnullプロパティを含めます(デフォルトではnullは無視されます)。targetPathを渡した場合にはこの引数は無視されます。
戻り値  コレクション in 取り出した値を格納する新しいコレクション

説明   

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
テーマ: コレクション
番号: 805251

This command can be run in preemptive processes

 
ページの目次 
 
履歴 

初出: 4D v16 R6

 
ARTICLE USAGE

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