I have some nested listmaps in which there are wires for some of these, though I want to return the current time . I'm new to scale, but I think the language has been created around the "function as variable", it is possible that it should be possible. So far I have the code, although it evaluates on the definition, while I would like to evaluate it every time the value is read.
val sql_dynamic = listMap ("user_history_create_date" - & gt; {(new simple data format ("yyyy-MM-dd")) format (new date ()), "fan_history_create_time" & Gt; {(New Simplified Format ("HH: mm: SS")). Format (New Date ())}); I have tried several syntax attempts to "define" these anonymous functions, but only managed to manage the errors.
You can try something like this: val sql_dynamic = ListMap ("foo" -> () =) & Gt; New SimpleDateFormat ("Yyyy-MM-dd") format (new date ())) println (sql_dynamic.get ("foo"). Get.apply ()) Here, I will add a Function0 [string] as the value of the map and it will be applied only when I remove it and it is clearly applied Edit In response to your comment, enter one of those values into values There is a bad idea that does not happen in any normal way. You can solve that by doing something like this: specialty datestring {def date: string} case class StaticDateString (date: string) extends Datestring class FunctionDateString (function :( Date = string () = DateString {def date = func ()} Object dataTest {DEAF main (args: array [string]) {val sql_dynamic = ListMap ("foo" - & gt; New functionDet string (() = & Gt; New SimpleDateFormat ("yyyy-MM format (new date)," bar "-> Staticdate Straightening (" 2013-01-01 ")) println (sql_dynamic.get ("Foo") Get.date println (get sql_dynamic ("bar"). Get.date)}}
No comments:
Post a Comment