Scala Double.isNaN用于检测非数字但不Double.isInf检测(正或负)无穷大.
为什么?我想检查参数是否是"真实"数字(即具有数值).将它转换为字符串并检查"inf"或其他东西会做到这一点,但必须有更好的方法吗?
就像在C++中一样: http //en.cppreference.com/w/cpp/numeric/math/isinf
使用Scala 2.10
我想从罗马号相匹配I,以IX用正则表达式.
val pattern = "(\\sI\\s|\\sII\\s|\\sIII\\s|\\sIV\\s|\\sV\\s|\\sVI\\s|\\sVII\\s|\\sVIII\\s|\\sIX\\s)".r
Run Code Online (Sandbox Code Playgroud)
这只能匹配大写.我想忽略这个案子.
我的测试字符串是"Mark iii ".
我想得到url-param id,但它不起作用.大家能帮助我吗?以下代码不起作用.
网址:
http://localhost:9000/rest/alerts?ids[]=123?ids[]=456
Run Code Online (Sandbox Code Playgroud)
Routes.conf
GET /restws/alerts{ids} controllers.AlertService.findAlertsForIds(ids: List[String])
Run Code Online (Sandbox Code Playgroud)
AlertService.java
public static Result findAlertsForIds(List<String> ids){
return ok("Coole Sache");
}
Run Code Online (Sandbox Code Playgroud) 在尝试构建我的play项目时,我得到了这个奇怪的解析异常.它抱怨文件中没有分号的分号.以下是错误消息和build.sbt(第12和13行)文件的摘录.
.../zentasks/build.sbt:12: error: eof expected but ';' found.
libraryDependencies += javaEbean
^
[error] Error parsing expression. Ensure that settings are separated by blank lines.
Run Code Online (Sandbox Code Playgroud)
Build.sbt文件:
...
libraryDependencies += javaJdbc
libraryDependencies += javaEbean
...
Run Code Online (Sandbox Code Playgroud)
注意:
我已经得到了解决方案,但想了一段时间提出这个问题/解决方案,以便像我这样的其他新手不会浪费任何时间来解决这个问题.
解决方案:我不明白为什么播放会抛出这个令人困惑的错误消息.我没看到那个分号在哪里.但是,解决方案是通过空行分隔依赖项,如下所示:
libraryDependencies += javaJdbc
libraryDependencies += javaEbean
Run Code Online (Sandbox Code Playgroud)
另请参阅:http://www.scala-sbt.org/release/docs/Getting-Started/Basic-Def.html#how-build-sbt-defines-settings
注意:随意添加到解决方案或更正它.
我有这个函数转换Array为a ParArray,给出线程数作为参数:
def parN[T](collection: Array[T], n: Int) = {
val parCollection = collection.par
parCollection.tasksupport = new ForkJoinTaskSupport(
new concurrent.forkjoin.ForkJoinPool(n))
parCollection
}
Run Code Online (Sandbox Code Playgroud)
现在我想使这个通用,这样它适用于除Array以下之外的集合:
def parN[S, T[S] <: Parallelizable[S, ParIterable[S]]](collection: T[S], n: Int) = {
val parCollection = collection.par
parCollection.tasksupport = new ForkJoinTaskSupport(
new concurrent.forkjoin.ForkJoinPool(n))
parCollection
}
Run Code Online (Sandbox Code Playgroud)
但是当我调用它时parN(Array(1, 2, 3), 2),我收到此错误:
inferred type arguments [Int,Array] do not
conform to method parN's type parameter bounds
[S,T[S] <: scala.collection.Parallelizable[S,scala.collection.parallel.ParIterable[S]]]
Run Code Online (Sandbox Code Playgroud)
另一方面,这是有效的:
val x: Parallelizable[Int, …Run Code Online (Sandbox Code Playgroud) 我正在尝试解决可能简单的问题,在我的"views"目录中,在典型的Play框架设置中,我想将模板(*.scala.html文件)分组,可能使用每个组的另一个文件夹,例如.我想拥有带有以下文件的客户文件夹:
createForm.scala.htmleditForm.scala.htmllist.scala.html到目前为止这么好但是当我尝试从我的控制器访问该视图引用时(例如Ok(views.html.list(..))- > Ok(views.customers.html.list(...)),我收到一个错误:
object customers is not a member of package views
Run Code Online (Sandbox Code Playgroud)
是否有关于如何使用多个视图,如何将它们收集到组中以及如何在其他视图或控制器中使用它们的最佳实践/方法.
Thx提前.
这是我的代码:
<form name="htmlform" method="post" action="html_form_send.php">
<div id="table">
<table width="400px" style="margin-top: 50px; margin-left: 20px; color: #FFF">
</tr>
<tr>
<td valign="top">
<label for="name">Name *</label>
</td>
<td valign="top">
<input type="text" name="name" maxlength="50" size="30" style="margin-bottom: 10px">
</td>
</tr>
<tr>
<td valign="top">
<label for="email">Email Address *</label>
</td>
<td valign="top">
<input type="text" name="email" maxlength="80" size="30" style="margin-bottom: 10px">
</td>
</tr>
<tr>
<td valign="top">
<label for="telephone">Telephone Number</label>
</td>
<td valign="top">
<input type="text" name="telephone" maxlength="30" size="30" style="margin-bottom: 10px">
</td>
</tr>
<tr>
<td valign="top">
<label for="enquiry">Enquiry *</label>
</td>
<td valign="top"> …Run Code Online (Sandbox Code Playgroud)