Skip to content

Instantly share code, notes, and snippets.

@tarunama tarunama/PHPの場合
Last active Aug 29, 2015

Embed
What would you like to do?
[Scala]PHPerのScala入門メモ(途中) ref: http://qiita.com/tarunama/items/f30420fa117c84274e1b
trait Access {
function howTo() {
echo "HowTo";
}
}
class Company {
use Access;
}
$access = new Company();
$access->howTo(); // HowTo
// switchに似たmatchがある.これはScalaっぽくない書き方。
string match {
case "hoge" => println("hoge")
case "foo" => println("foo")
case "bar" => println("bar")
case _ => println("placeholder")
}
val ary = Array(1, 2, 3)
for (num <- ary)
yield num * 2
trait Access {
def howTo() {
println("HowTo")
}
}
class Company extends Access {
override def toString = "hoge"
}
val company = new Company
company.howTo() // HowTo
val integerList = List(1, 2, 3)
// リストは変更可能
val stringArray = Array("hoge", "one", "foo")
// 配列は変更可能
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.