2008-05-01ãã1ã¶æéã®è¨äºä¸è¦§
é¢æ°ã®ãã©ã¡ã¼ã¿ã«ãimplicitããã¤ãã¦ããã¨ãé¢æ°ã®å¼ã³åºãæã«ãã®å¼æ°ãçç¥ã§ããããã«ãªãã¾ããçç¥ãããå¼æ°ã«ã¯ãã¡ã½ããã®å¼ã³åºãå ã³ã³ããã¹ãã§ä¸çªããã£ã½ãimplicitä»ãã®å¤ãã³ã³ãã¤ã©ãé¸æãã¦æ¿å ¥ãã¦ããã¾ãã ãimplicitãã¯â¦
ã¤ã³ã¹ã¿ã³ã¹ã¤äºã·ã£ã©ã¤ã¶ã使ã£ã¦åæåããMapãRMIã§éä»ãããã¨ãããã¨ã©ã¼ã«ãªã£ããåé¡ã®Mapã®åæåã³ã¼ãã¯ä»¥ä¸ã RMIObject rmiobject = new RMIObject(); rmiobject.setMap(new HashMap<String, String>(){{ put( "a", "aaa" ); put( "b", "bbb" ); put( "c",</string,>â¦
ãvalãã§ä¸å¤ã®å¤ãå®ç¾©ããéã«ããlazyã修飾åãã¤ããã¨ãå¤ãé 延è©ä¾¡ããã(æåã«ã¢ã¯ã»ã¹ãããã¨ãã«ã®ã¿è©ä¾¡ãããå®ç¾©æã«ã¯è©ä¾¡ãããªã)ããã«ãªãã¾ãã ãlazyãã¯ãvalãã«ã®ã¿è¨å®ã§ãã¾ãããvarãããdefãã«è¨å®ãããã¨ã¯ã§ãã¾ãããâ¦
è¦ç´ ãå¿ è¦ã«ãªã£ãã¨ãã«ä½æãã¦è¿ãä»çµã¿ã¨ãã¦ã¯Streamã®ã»ãã«Iteratorãããã¾ããhasNext(),next()ãæã¤ã¢ã¬ã§ããJava使ãã«ã¯ãã£ã¡ã®æ¹ãããããããããã以ä¸ã¯ãã£ããããæ°ãé ã«è¿ãã¤ãã¬ã¼ã¿ã®ãµã³ãã«ã§ãã Iteratorãç¶æ¿ããç¡åã¯â¦
ãã¹ããå®è¡ããã¿ã¼ã²ãããæ¸ãã¾ããããã¹ãã®ã³ã³ãã¤ã«âå®è¡âã¬ãã¼ãä½æãè¡ãªãã¾ãã <path id="class.compile.path"> </path> <path id="test.compile.path"> <path location="lib/junit.jar"/> <path refid="class.compile.path" /> </path> </path></path>
Streamã¯è¦ç´ ãå¿ è¦ã«ãªã£ãã¨ãã«ä½æãããList(ã¿ãããªã¢ã)ã§ãã è¦ç´ ã¯å¿ è¦ã«ãªã£ãã¨ãã«åãã¦ä½æãããã®ã§ã è¦ç´ ã®ä½æã«æéããããå ´åã«åæä½æã³ã¹ããæãããã¨ãã§ãã¾ãã ã¾ããè¦ç´ ãå ¨é¨è¾¿ããªãå ´åã«ç¡é§ãªä½æã³ã¹ããåæ¸ã§ãâ¦
æ¨æ¥æ¸ãããªãã¸ã§ã¯ãã®ã¡ã½ããå¼ã³åºããã ãã§å®è¡ã§ãã件ã«ã¤ãã¦ãã¿ããã¾ããããã³ã¡ã³ããé ãã(ãããã¨ããããã¾ã!)ã®ã§ãä»æ§æ¸ã確èªã ã©ãããã¡ã½ããå¼ã³åºãã¨æ¼ç®åãã¾ã£ããå¥ç©ã¨ããèªèãããããééã£ã¦ããããã ãScalaâ¦
å¦çãnåç¹°ãè¿ãããã¨ãã¯ãuntilãã使ãã¾ãã // å¦çã10åç¹°ãè¿ããã for ( i <- 0 until 10 ) println( i ) å®è¡çµæã§ãã 0 1 2 3 4 5 6 7 8 9ã0 until 10ããæåè¦ãã¨ãããªãã ãã?ãã¨æã£ããã§ãã(ããããæ¼ç®åãããã®ããªã¼ã¨ãâ¦
GitHubããããããã¨ãã話ãèãã®ã§ä½¿ã£ã¦ã¿ããã¨æã£ã¦ã¢ã«ã¦ã³ããä½ã£ãã®ã ãã©ããªãã¸ããªã«httpã§ã¢ã¯ã»ã¹ããæ¹æ³ããããã¾ããã»ã»ã»ãgitèªä½ã¯httpã§ã®ãªãã¸ããªã®å ¬éããµãã¼ããã¦ãããããªã®ã§ãã§ããã¢ãã ã¨æã£ã¦ãããã ãã©ããâ¦
foræã使ãã¨ãé åãListã®æä½ãç°¡åã«è¡ãªããã¨ãã§ãã¾ãã é åãåæãã åç´ã«é åãåæããã«ã¯æ¬¡ã®ããã«æ¸ãã¾ãã for ( <ãã¿ã¼ã³å> <- <é å> ) <å¦ç> ããã§ä»¥ä¸ã®å¦çãè¡ãªããã¾ãã é åã®å¤ãä¸ã¤åãåºãã¦ãã¿ã¼ã³åã示ãå¤æ°ã«â¦
é£ã®çä¸ããã¸ã§ã¯ãã®ã¤ãã¤ã³ã¼ãæ¢ããä»°ãã¤ãã£ãã®ã§ãã¨ããããFindBugsã«ããã¦ã¿ãã¨ãâãããªã®ãåºãã class Hoge { private String foo; public void setFoo( String foo ) { synchronized( this.foo ) { // fooã¸ã®æ´æ°ã1ã¹ã¬ããã«å¶éãâ¦
class TestException<T> extends Exception {} âã¿ãããªä¾å¤ãä½æãããã¨ãã¦ã¨ã©ã¼ã«ããThe Java Language Specificationããèªãã¨8.1.2 Generic Classes and Type Parametersã«è¨è¼ããã£ãã It is a compile-time error if a generic class is a direc</t>â¦
ã¾ããã¤ãã¯ã¾ããããªã®ã§ã¡ã¢ã ç¾è±¡ ãµã¼ãã¼ãåæ§ç¯ããããDB2ã®ROW_NUMBERé¢æ°ã®å®è¡ã§ã¨ã©ã¼(SQLSTATE: 42884)ãçºçããããã«ãªã£ãã åããã¼ã¸ã§ã³ã®DB2ãå©ç¨ãã¦ããä»ã®ãµã¼ãã¼ã§ã¯æ£ããåä½ãã¦ããã åãã¢ã¸ã¥ã¼ã«ã使ç¨ãã¦ããä»ã®â¦
ã¨ãªãã®ãã¼ã ã®ããã¸ã§ã¯ããçä¸æ°å³ã§ã¤ãã«åºç¨¼ãã«åºãç¾½ç®ã«ãªã£ãããã§ããããã®ããã¸ã§ã¯ãã§ã¯GuiceãSpringãSeasarã使ã£ã¦ãªãã®ã§ãã¢ã¹ãã¯ããããã£ã¨ä½¿ããªãããªãªã¼ã¹ãè¿ãããä»ããã¢ã¸ã¥ã¼ã«è¿½å ããã®ãã¡ã³ãã¦ã ãªã¼ãã»ããâ¦
å¯å¤é·ã®é å(javaã®List)ã使ãããå ´åãscala.Listã使ãã¾ãã åããããªæ©è½ãæã¤ã¯ã©ã¹ã¨ãã¦ãscala.Arrayãããã¾ããã scala.Arrayã¯åºå®é·ã§ãJavaã«ãããé å(new int[]ã¨ã)ã«è¿ãã scala.Listã¯å¯å¤é·ã§ãJavaã«ãããListã«è¿ãã å¯å¤é·â¦
è¤æ°ã®å¤ãè¿ããããã©ã³ã³ããã¨ããã¯ã©ã¹ãå®ç¾©ããã®ãã¡ã³ãã¤ãã¨ããã¨ãã«ã¿ãã«ã使ãã¾ãã ã¿ãã«ã¯è¤æ°ã®å¤ãä¿æããçµã¿è¾¼ã¿ã®ã¯ã©ã¹(scala.Tuple2 .. etc)ã§ãã è¦ç´ æ°ã«å¿ãã¦ããããå¥ã®ã¯ã©ã¹ãç¨æããã¦ããã®ã§ãå¿ è¦ãªè¦ç´ æ°ã«ããâ¦
FileChannel#lock()ãå®è¡ããããã¯ã®åå¾ãå¾ ã£ã¦ããã¹ã¬ããã«å²ãè¾¼ãã¨ããFileLockInterruptionExceptionãçºçãããã¨ãæ¸ãã¦ãã(ããã«èªãã)ãã ãã©ãä½ãèµ·ããªãã»ã»ã»ã // ããã¯ãããã¡ã¤ã« final File file = new File( "./test.tmp" â¦
åãã©ã¡ã¼ã¿ã«ã+ãã-ããã¤ãããã¨ã§ããã©ã¡ã¼ã¿åãããã¯ã©ã¹ã®ä»£å ¥å¶éãå°ãç·©ãã§ãã¾ãã ãã©ã¡ã¼ã¿åãããã¯ã©ã¹ã®ä»£å ¥å¶éã¨ã¯? 次ã®ãããªãåãã©ã¡ã¼ã¿ãåãåãã¯ã©ã¹ãããã¨ãã¦ã // åãã©ã¡ã¼ã¿ãåãåãã¯ã©ã¹ class Holder[A](vâ¦
é å(scala.Array)ã®åºæ¬çãªä½¿ãæ¹ã«ã¤ãã¦ã¾ã¨ãã çæ ãnew Array[]()ãã§çæã // çæ var array = new Array[Int](5) nçªç®ã®è¦ç´ ã®è¨å® ãé å() = ãã使ããã[]ããããªãã! // nçªç®ã®è¦ç´ ãè¨å® array(2) = 20 // 2çªç®ã®è¦ç´ ã20ã«ã arrayâ¦
æååããã¤ãé åã«å¤æããString#getBytes()ã§ãããç°å¢ã«ãã£ã¦ã¨ã³ã³ã¼ãã§ä½¿ãããããã©ã«ãã®æåã»ãããéãããã注æãå¿ è¦ã§ãããããã©ã«ãã¯UTF-8ãã¨ãæãè¾¼ãã§ãã¦ãã ãã¶ãã¾ãã£ã¦ãã¾ãã¾ããã»ã»ã»ãString#getBytes()ã®å®è£ ãã¿â¦
ã£ã¦ãã§ãããã§ãããListã¨ãã®ã³ã¬ã¯ã·ã§ã³ã«çªã£è¾¼ãã§ä¸æ°ã«ã·ãªã¢ã©ã¤ãºããªãã¨ãããªã!ã¨ãåæã«æãè¾¼ãã§ãã¾ããã import java.io._ // ã·ãªã¢ã©ã¤ãºå¯¾è±¡ class Kitten( name:String, age:int ) extends Serializable { override def toStrinâ¦
Rubyã§ä½¿ããããã·ã¥é¢æ°ã®æ§è½ã測ã£ã¦ã¿ãã Rubyã®ã¡ãã»ã¼ã¸ãã¤ã¸ã§ã¹ãã©ã¤ãã©ãªã§ä½¿ããããã·ã¥é¢æ°+String#hashã®å¦çæéãè¨æ¸¬ åå¦çã10000åå®è¡ãã¦åè¨å¦çæéãåºãã çµæã¯ä»¥ä¸ã ããã·ã¥é¢æ° æè¦æé(ç§) sha1 0.913 sha256 1.572 â¦
Classã®ç¶æ¿ãã¡ã³ãã¼ã®ãªã¼ãã¼ã©ã¤ããå¶éããæ©è½ã¨ãã¦ãfinalãã¨ãsealedãã使ãã¾ãã ãfinalãã¯ã¯ã©ã¹ãã¡ã³ãã¼ã«å¯¾ãã¦è¨å®ã§ãã修飾è©ã§ãã finalãè¨å®ãããã¯ã©ã¹ã¯ç¶æ¿ã§ãã¾ããã finalãè¨å®ãããã¡ã³ãã¼ã¯ãªã¼ãã¼ã©ã¤ãã§ãã¾â¦
Scalaã®åãã©ã¡ã¼ã¿ã§ã¯ããã©ã¡ã¼ã¿ã§åãä»ããã¯ã©ã¹ã®ç¯å²ãå¶éãããã¨ãã§ãã¾ããJavaã®ãsuperãã¨ããextendsãã¿ãããªæ©è½ã§ãã ã[ ]ãã¨ãããã¨ã§ããã¯æ´¾çã®ä½ããã«å¶éã§ãã¾ãã ã[ >: ]ãã¨ãããã¨ã§ããã¯ã¾ãã¯ãã®ä¸ä½ã¯ã©ã¹ã®â¦
Scalaã®Objectã«ã¤ãã¦ãThe Scala LanguageSpecificationãèªãã§ãã¤ã³ããã¾ã¨ãã¾ãã 使ãã¿ã¡ å®æ°(staticå¤æ°)ãstaticã¡ã½ãããä½ãã®ã«ä½¿ããéã«scalaã«ã¯staticããªãã å é¨çã«ã¯ã©ããªã£ã¦ãã®? 次ã®ãããªobjectã®å®ç¾©ã¯ã object X extendsâ¦
ScalaByExample - Example 6 Classes and ObjectsãããScalaã®Classã¨ãTraitã®éãã«ã¤ãã¦ããããç¯å²ã§ã¾ã¨ãã¦ã¿ã¾ãã Scalaã®Classã¨ãTraitã®æ¯è¼è¡¨ Class Abstract Class Trait Object æ½è±¡ã¡ã½ãããæã¦ãã? à â â à ã¡ã½ããã®å®è£ ãæ¸ããã?â¦
ScalaByExample - Chapter 5.2 Curryingãããé¢æ°ãæ»ãå¤ã¨ãã¦è¿ãé¢æ°ãä½ã£ã¦ã¿ã¾ãã å¼æ°ã§æ¸¡ãå ´åã¨åæ§ã«ãæ»ãå¤åãã: => ãã¨ãããã¨ã§é¢æ°ãè¿ããã¨ã示ãã¾ãã å¾ã¯æ»ãå¤ã¨ãã¦é¢æ°ãè¿ãã°OK // é¢æ°ãè¿ãé¢æ°ã®å®ç¾© // æ»ãå¤åãã<â¦
ScalaByExample - Chapter 5 First-Class Functionsã¨ScalaByExample - Chapter 5.1 Anonymous Functionsã®ãã¤ã³ãã¾ã¨ãã é¢æ°ã¯å¤ Scalaã®é¢æ°ã¯å¤ã§ããå¼æ°ã¨ãã¦æ¸¡ããããæ»ãå¤ã¨ãã¦è¿ããã¨ãã§ãã¾ãã以ä¸ã¯ãé¢æ°ãå¼æ°ã¨ãã¦åãåãé¢æ°ã®ä¾â¦
ScalaByExample - Example 4.6 Tail RecursionãããScalaã§ã¯æ«å°¾å帰ã¯æé©åããã¾ããç¡é§ãªã¹ã¿ãã¯ãçæããªãããã«ãå帰ãå©ç¨ããé¢æ°ã¯æ«å°¾å帰ã¨ãªãããã«è¨è¨ãã¾ããããã¨ã®ãã¨ã æ«å°¾å帰ã¨ã¯ å帰å¼ã³åºããå«ãæç¶ãããèªåèªèº«ã®å¼â¦
ScalaByExample - Example 4.3 Conditional ExpressionsããScalaByExample - Example 4.5 Nested Functionsãããã®ãã¤ã³ãã¾ã¨ãã if-else ã¯å¤ãè¿ã Scalaã®if-elseå¶å¾¡æ§æã¯å¤ãè¿ãã¾ãããªã®ã§ä¸é æ¼ç®åçã«ä½¿ããã¨ãã§ããã¨ã®ãã¨ã // if ã¯â¦