• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Scala jeff
 

Scala jeff

on

  • 3,024 views

 

Statistics

Views

Total Views
3,024
Views on SlideShare
2,556
Embed Views
468

Actions

Likes
2
Downloads
63
Comments
1

8 Embeds 468

http://www.jeffkit.info 440
http://www.fallever.com 8
http://xianguo.com 8
http://reader.youdao.com 7
http://static.slidesharecdn.com 2
http://fallever.com 1
http://jeffjie.webfactional.com 1
http://webcache.googleusercontent.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • http://zoomquiet.org/res/m/r/110123-techparty-gz/110123_175M_jeff-scala.MP3
    附上现场的录音。
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Scala jeff Scala jeff Presentation Transcript

    • learn in half an hour http://jeffkit.info
    • Scalable language (actor)JVM ,also .net DSL
    • Scala
    • tiobe 2010/1
    • Scala!
    • twitter scala
    • foursquare rogueA Lift/MongoDB Query DSLVenue where (_.mayor eqs 1234) and (_.categories contains “thai”) orderAsc (_.popularity) fetch (10)
    • &Scala
    • Scala
    • Code Time
    • println (“hello Scala”)
    • 1 package info.jeffkit object HelloScala { 2 def main(args : Array[String]) : Unit = { 3 println("hello world") 4 } } 1 2 object -> main 3 4
    • techparty say helloDSL
    • package info.jeffkit1 class Group(val name:String){ def say(msg:String):Unit = { println ("The Group " + this.name + " say : " + msg) } } object HelloScala { def main(args : Array[String]) : Unit = { println("hello scala") 2 val techparty = new Group("techparty") techparty.say("hello scala") 3 techparty say "im the magic of DSL" 4 } } 1 2 3 4 DSL
    • hello
    • 1class Group private (val name:String){ def say(msg:String):Unit = { println ("The Group " + this.name + " say : " + msg) }}object Group{ 2 private val groups = Map( 3 "techparty" -> new Group("techparty"), "barcamp" -> new Group("barcamp"), "openparty" -> new Group("openparty") ) def getGroup(name:String) = {4 if (groups.contains(name)) groups(name) else null }} 1 2 3 Map 4
    • 1def play(game:String,members:Array[Member],perform:Member => Unit) = { println ("The group is playing a game : " + game ) members.foreach{ member => perform(member) 3 } }class Member(val name:String,val topic:String){ def this(name:String){ this(name,null) 2 }}val members = Array( new Member("laiyonghao","male",true,"2010,My choices"), 4 new Member("jeff","male",true,"learn scala in haft an hour"), new Member("iceberg") ) 1 2 3 List foreach 4 List
    • //lambda 1 techparty.play("introduce your self", members, member => println ("My name is " +member.name)) // 2 def present(member:Member) = { if (member.topic != null) println (member.name + " is presenting.") } techparty.play("present", members, present) 3 // , val potluck = techparty.play("potluck", members, _:Member => Unit) potluck(_.name + " is eating") // ============ curry =============== 4 techparty.play_curry("dismiss", members){ member => member.name + " is leaving and going home" } 1 lambda 2 3 4 curry
    • python fans mixin
    • 1 trait Fan{ def like() = "techparty" } trait JavaFan extends Fan{ override def like() = "java " + super.like() } 2 trait PythonFan extends Fan{ override def like() = "python " + super.like() } 3 val member = new Member("jeff","learn scala in haft an hour") with JavaFan with PythonFan 4 member.like() 1 ,trait 2 trait class 3 mixin with) 4 mixin
    • 1def search(condition:Any):String = { 2 condition match { case "sleepy" => println("you look sleepy,sleep 1 second") Thread.sleep(1000) 3 case q:String => println("search by a keyword :" + q) case ("name",name:String) => println("search by name : " + name) case (year:Int,month:Int) => println("search by year " + year +" and " + month) 4 case _ => println("cant handle your search");return "fail" } "success" } 1 2 3 4
    • val receiver = self 1 actor { receiver ! techparty.search("jeff",2010) 2 } 3 val at = actor { receiver ! (self,techparty.search("sleepy")) } println("waiting for actor to finish") 4 for(i <- 1 to 2){ receive { 5 case (at,status:String) => println("hey,at is finish his job,and thestatus is: " + status) case "success" => println("search finish") case "fail" => println("search fail") } } 1 actor 2 3 actor 4 for 4 case
    • Thank you!