我建立使用阶将筛选基于在DSL状态数据的DSL通过拉姆达参数的名称。查找斯卡拉
功能过滤器:
def filter(f: (Int) => (Int)) {
// find what is the name (age) of lambda passed
// query db with column name age and apply function f and return value
}
使用DSL作为:
filter( (age) => age > 10)
我不能找到一种方法,要知道,在DSL age
时,有没有办法?
暂时,我传递的字符串作为第一个参数如下图所示:
filter("age", (age) => age > 10)
和改变过滤器采取的第一个参数为列名。
我想简化DSL。
你可以添加'filter'函数的实际实现吗? –
这将需要一个宏(如果有可能,我不知道)。 –
如果你只是把它称为'filter(“age”,(_> 10))'',那么它不会简单吗? –