有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Play 2.0模板参数中的括号

我使用java的Play2.0工作了大约一个月,有一件事我真的无法理解。模板是如何工作的?向他们传递参数的最佳方式是什么

两者之间有什么区别

@(name: String, value: String)

@(name: String)(value: String)

这只是为了方便吗

我发现了一个揭开秘密面纱的问题,但它没有告诉我应该选择哪种方式


共 (2) 个答案

  1. # 1 楼答案

    在第一种情况下,将多个参数传递给函数。在第二种情况下,您使用的是咖喱。根据维基百科:

    In mathematics and computer science, currying is the technique of transforming a function that takes multiple arguments (or an n-tuple of arguments) in such a way that it can be called as a chain of functions each with a single argument (partial application). http://en.wikipedia.org/wiki/Currying

    每个用例的最佳区别是什么

    编辑:注意模板只是Scala函数

  2. # 2 楼答案

    典型的例子是:

    //梅因。斯卡拉。html

    @(title: String)(content: Html)
    ....
    

    //索引。斯卡拉。html

    @main("Foo Title") {
      <div>this content Html param passed in as a block {}</div>
    }
    

    与:@(title: String, content: Html)

    语法不太好:

    @main("Foo Title", {
      <div>...</div>
    })