示例:
class Item {
getFoo();...
getBar();...
}
$methods = ['Foo','Bar'];
...
foreach($methods as $method){
$methodName = 'get'.$method.'()';
$item->{$methodName}; //Notice: Undefined property: Item::$getFoo()
}
//"Item->$getFoo()" instead of "Item->getFoo()" probleme is $
答案 0 :(得分:0)
def add_columns(dataframe, column_list):
for col in column_list:
self = dataframe.withColumn(str(col), lit(None).cast(StringType())))
return dataframe