先从简单的情况入手,假设 f1 的类型是 A => B, 看看
f2 andThen {
_ andThen f1
}
到底是什么意思 先去掉语法糖,完整形式为:
先从简单的情况入手,假设 f1 的类型是 A => B, 看看
f2 andThen {
_ andThen f1
}
到底是什么意思 先去掉语法糖,完整形式为:
import util._ | |
abstract class SrcProtocol(val id: String) | |
case class CompileSrc(override val id:String) extends SrcProtocol(id) | |
case class TestSrc(override val id:String) extends SrcProtocol(id) | |
case class SystemSrc(override val id:String) extends SrcProtocol(id) | |
abstract class DstProtocol(val id: String) |
def name2id1(name: String): Option[String] = name match { | |
case "name1" => Some("id1") | |
case "name2" => Some("id2") | |
case "name3" => Some("id3") | |
case _ => None | |
} | |
def name2id2(name: String): Option[String] = name match { | |
case "name1" => None | |
case "name2" => Some("id2") | |
case "name3" => Some("id3") |
realm=Sonatype Nexus Repository Manager | |
host=nexus.company.com | |
user=admin | |
password=admin123 |
import tools.nsc.interpreter.IMain | |
import tools.nsc.Settings | |
object CommaSeperatedData extends App { | |
val data = """ "Doe, John", 35, 225, "5'10\"", "555-0123" """ | |
val settings = new Settings | |
settings.usejavacp.value = true | |
val n = new IMain(settings) | |
n.interpret("List(" + data + ")") |
package flux | |
/** | |
* Created by IntelliJ IDEA. | |
* User: xf | |
* Date: 14/10/20 | |
* Time: 下午5:49 | |
*/ | |
trait Payload[T] { |
I'm having trouble understanding the benefit of require.js. Can you help me out? I imagine other developers have a similar interest.
From Require.js - Why AMD:
The AMD format comes from wanting a module format that was better than today's "write a bunch of script tags with implicit dependencies that you have to manually order"
I don't quite understand why this methodology is so bad. The difficult part is that you have to manually order dependencies. But the benefit is that you don't have an additional layer of abstraction.
object PathList { | |
def unapplySeq(path: String): Option[Seq[String]] = | |
if(path.isEmpty) None | |
else Some(path.split("/")) | |
} | |
def testMatch(str: String): Boolean = str match { | |
case PathList("org", "scalaconsole", "fxui", "main", "ace-builds", sub) => true | |
case PathList("org", "scalaconsole", "fxui", "main", "ace-builds", sub, xs@_*) if sub != "src-min-noconflict" => true |
val keywords = Set("class", "public", "private", "protected") | |
def wordCount(is: java.io.InputStream): Map[String, Int] = { | |
var result = Map[String, Int]() | |
val scanner = new java.util.Scanner(is) | |
while(scanner.hasNext) { | |
val word = scanner.next | |
if(keywords.contains(word)) { | |
if(result.contains(word)) { |