1æ¥ç©ºãã¦ãã¾ãã¾ããããå¼ãç¶ããµã¤ã¼ã®ãªãã¸ã§ã¯ãæåè¨èª ã¨ãã¦ã®Scalaã説æãã¦ããã¾ãã é«éé¢æ°ï¼ãã ã®ã¡ã½ãã ããã¯ã¸ã§ã¼ã¯ã§ã¯ãªããæ¬å½ã«ãã ã®ã¡ã½ãããªã®ã§ããã¨ããããã説æã¯å¾ã«ãã¦ã代表çãªé«éé¢æ°ã§ãããmapã®Scalaå®è£ ãè¦ã¦ã¿ã¾ããã*1ã def map[A, B](list: List[A], fun: A => B): List[B] = { val newList = new ArrayList[B] val it = list.iterator() while(it.hasNext()) { newList.add(fun.apply(it.next())) } newList } å©ç¨ä¾ã¯ä»¥ä¸ã®ããã«ãªãã¾ãã val a = new ArrayList[String]{ add("A"); add("B") } println(map(
{{#tags}}- {{label}}
{{/tags}}