And now, a friendly message from your local Tell, donât ask Department. Example 1 Not so good: <% if current_user.admin? %> <%= current_user.admin_welcome_message %> <% else %> <%= current_user.user_welcome_message %> <% end %>
1. åãããªããããã説æãèªãã§ãåãããªãã â 1.1. æªã ã«åãããªã Java çãªãã¸ã§ã¯ãæå ä»æ¥ã³ Java çãªãã¸ã§ã¯ãæåã®èª¬æãªãã¦æã®æ°ã»ã©ãããããªæ°ããã¾ãããããã§ããªããããã§åãã£ãï¼ãã¨ãã説æã«è¾¿ãã¤ããªãä¸éãªäººãããããã§ãããã¾ãããã ãè²ã ãªèª¬æã溢ãã¦ãããéã«ã©ããèªãã°è¯ãã®ãã¯ã±åãããªããªã£ã¦ãã¾ãã®ããããã¾ããããã£ããèªãã§ãç解ã§ããªãã£ãã®ã§ããã°ããã£ã¨ãã®èª¬æã¨èªè ã®ç¸æ§ãæªãã£ããã§ãããã⦠ã¨ããããã§ãåã Java çãªãã¸ã§ã¯ãæåãå ¨ã£ã£ã£ã£ç¶ããã£ã½ã£ã¡ãåãããªãã¨ãã人ã«åãã¦èª¬æããè¨äºãæ¸ããã¨æãã¾ããããã§ãªã人ã«ã¯ç¡ä¾¡å¤ãªè¨äºã§ãã®ã§ãã©ã¦ã¶ã®ãæ»ãããã¯ãªãã¯ãã¾ãããã â 1.2. ããªãã¸ã§ã¯ãæåãã¨ããåã®åã®å³¶ããã ãªãã¸ã§ã¯ãæåã«ã¯ããã¤ãã®å°éç¨èªããã£ã¦ãå¦ç¿
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(
Rubyã«ã¯ã³ã¼ãçã表ããªãã¸ã§ã¯ããè¤æ°ããã Method , UnboundMethod , Proc ã§ããã Continuation ã¯å°ãéããã©ãå®è¡ã³ã³ããã¹ããè¨æ¶ãã¦ãããªãã¸ã§ã¯ãã¨ããæå³ã§ã¯è¿ããã®ãããããã Ruby Way ãã«ã¯ããããããããããããã¨ã«ã¤ãã¦ãé©ãã»ã©ã®ãã¨ã§ã¯ããã¾ãããã¨æ¸ãã¦ããããã©ãç§ã¯é©ãããã§ãããããå¾®å¦ã«éãã®ã ãå°ã£ãããã ãããã便å©ãªã®ãããããªããã ããã§ä»åã¯ãããã®æ¦è¦ãçºãã¦ã¿ããã¨æãã æ®éã®ã¡ã½ãã defã§ã¡ã½ãããå®ç¾©ããã®ãä¸çªæ®éã ããªã class C def greeting(arg) puts "C#greeting reveived #{arg}" end def iterator yield 'iterator 1st' yield 'iterator 2nd' yield
Subject: [ruby-dev:11450] Re: Ruby I18N From: Tanaka Akira <akr@ 7 o > Date: Thu, 9 Nov 2000 12:24:06 +0900 References: 11380 11382 11393 11396 11397 11398 11399 11401 11423 11426 11427 11428 In-reply-to: 11428 In article <E13tNkT-00030l-00 / ev.netlab.zetabits.co.jp>, matz / zetabits.com (Yukihiro Matsumoto) writes: > ãããããªãã§æåãªãã¸ã§ã¯ãã§ãªãæ´æ°(ã³ã¼ããã¤ã³ã)ã«åº > å·ããã®ãã¨ããã¨ããã¯ãäºææ§ã¨ã¡ãªãããè¦ããªããããªã > ã§ãããã¨ããããã§ã[
ããªã¢ã¼ãã£ãºã ããªã¢ã¼ãã£ãºã ï¼Polymorphismï¼ã¨ã¯ï¼è¤æ°ãæå³ããæ¥é èªãpoly-ãã¨å½¢æ ãæå³ãããmorphãã¨ã®åæã«ï¼æ¥å°¾èªã-ismããä»ãããã®ã§ããã¤ã¾ããè¤æ°ã®å½¢æ ã§ãããã¨ãã¨ããæå³ã§ããå訳ãã¦ãå¤æ ãã¨å¼ã°ãããã¨ãããã¾ãã å¥ã®è¨ãæ¹ãããã°ï¼å¤æ ã¨ã¯è¤æ°ã®ç¨®é¡ã®ãã®ãããããåããã®ã§ãããã®ããã«æ±ããã¨ãã§ãããã¨ãè¨ãã¾ãã ããã ãã ã¨ï¼ãªãã®ãã¨ã ãåãããªããããããªãã®ã§ï¼ä¸ã¤ã®ãã¨ãã使ãã¾ãããã ããã«3ã¤ã®ç®±ãããã¾ããç®±ã«ã¯ãããããµããããï¼ãµããä¹ãã¦ããã ãã®ãã®ï¼éµãä»ãããã®ï¼ãªãã³ã§çµãã§ãããã®ã«åããã¾ããç®±èªä½ãé常ã«é«ä¾¡ãªã®ã§ï¼ããããã®ç®±ã«ã¯å°ä»»ã®ãªãã¬ã¼ã¿ãä»ãã¦ãã¦ï¼ç®±ã«å¯¾ãã¦ãªã«ããããã¨ãã«ã¯ï¼ãªãã¬ã¼ã¿ã«å½ä»¤ãã¾ãï¼å³1[æ¡å¤§è¡¨ç¤º]ï¼ã 3種é¡ã®ç®±ã¯ããããéãæ¹ãéã£ã¦ãã¾ãããããã
Scalaã®ã¸ã§ããªãã¯ã¹ãå°ãå¦ãã§ã¿ã¾ããã(ãªããéãããããï¼ã¨ãããã°ãããã³ããé¡ããã¾ãm(_ _)m) Javaã®ã¸ã§ããªãã¯ã¹ã§ã¯ãåãã©ã¡ã¼ã¿ã¯å ±å¤/åå¤ã§ã¯ãªã Javaã§ãããªã³ã¼ããæ¸ãã¦ã³ã³ãã¤ã©ã«æããããã¨ãªãã§ããã public interface Animal { } public class Dog implements Animal{ } public class App { public static void main(String[] args) { ArrayList<Animal> animals = new ArrayList<Dog>(); } } ArrayList<Animal> animals = new ArrayList<Dog>(); ã¨ããã¨ãåããã¹ãããã¨ãªãã¾ãã ã¤ã¾ããArrayListã®ãµãåã¨ãã¦ãArra
ããããGenericsã®ã¡ã«ããºã ã«ã¤ãã¦ã¯ãããåºæ¬çãªé¨åã«ã¤ãã¦ã¯Javaã¨åãããã«è¦ãããåãã©ã¡ã¼ã¿ã®å¢çï¼è¦ªã®åã¨ãã¦XXXãæã£ã¦ãªãã¨ãããªãã¨ããåã®åã¨ãã¦XXXãæã£ã¦ãªãã¨ãããªãã¨ãï¼ã«ã¤ãã¦ãåãã大ããéãã®ã¯ãåãã©ã¡ã¼ã¿ã®ç¶æ¿é¢ä¿ã¨ããã©ã¡ã¼ã¿ãã¦ã³ããããç·ç§°ã¯ã©ã¹ï¼ä»¥ä¸ãé¢åãªã®ã§"ç·ç§°ã¯ã©ã¹"ã¨æ¸ãï¼èªä½ã®ç¶æ¿é¢ä¿ã¨ã®é¢ä¿ãããªãã¡å ±å¤ï¼Co-Variantï¼ã«é¢ããé¨åã ã¨ãã£ã¦ããå ±å¤èªä½ã«ãã¾ã詳ãããªãã®ã§ããã°ããå ±å¤ã«ã¤ãã¦åå¼·ãã¦ã¿ãã å ±å¤ èª¿ã¹ã¦ãå®ç¾©ãããå®ç¾©ãåºã¦ããªãã¦å°ã£ããã¨ããããã¯é¢é£ãããããªè¨äºã¨ãã¦ä»¥ä¸ã®ãããªãã®ããã£ãã Javaã®çè«ã¨å®è·µ: Genericsãäºè§£ï¼ Javaã®çè«ã¨å®è·µ: Genericsã®ã¯ã¤ã«ãã«ã¼ãã使ãããªãã第1å Javaã®çè«ã¨å®è·µ: Genericsã®ã¯ã¤ã«ãã«ã¼ã
ãã©ã¡ã¼ã¿å¢ç åãã©ã¡ã¼ã¿ã«ã¯ä»¥ä¸ã®3ã¤ã®å¢çãè¨å®ã§ããã ä¸éå¢ç(upper bound) ä¾ hoge[A <: T] A ã T ã®ãµãã¿ã¤ãã§ãªããã°ãªããªã ä¸éå¢ç(lower bound) ä¾ hoge[A >: T] A 㯠T ã®ã¹ã¼ãã¼ã¿ã¤ãã§ãªããã°ãªããªã å¯è¦å¢ç(view bound) ä¾ hoge[A <% T] A ã T ã¨ãã¦æ±ãã(æé»ã®åå¤æã«ããå¤æå¯è½ã¾ã㯠A ã T ã®ãµãã¿ã¤ã) é常ã®åãã©ã¡ã¼ã¿ æ®éã®åãã©ã¡ã¼ã¿ããããããã以ä¸ã® Holder ãèããã class Holder[A] { private var contents:A = _ def set(value:A) {contents = value} def get:A = contents } 以ä¸ã®ããã«åãã©ã¡ã¼ã¿ã¨ãã¦Intãæå®ããå ´åãå½ç¶ Doub
ææã®ãã£ããã§è©±é¡ã«ãªã£ã¦ãæµãå»ãããã ã£ãã®ã§ãã£ãããªããã転è¼ãã¦ããããäºå¾æ¿è«¾ã§ã MIYAMOTO Daisuke: åã®ç¶æ¿ã¨å®è£ ã®ç¶æ¿ãåºå¥ããæ¹æ³ããªããã ããªã 西尾泰å(nishio.hirokazu): åãç¶æ¿ãããã«å®è£ ãç¶æ¿ããããâãã移è²ã§ãã£ã¦ãã¨ããªï¼ MIYAMOTO Daisuke: ããããããããã¯ã©ã¹ã«ãåã¨ãã¦ã®å½¹å²ãã¨ãå®è£ ã¨ãã¦ã®å½¹å²ãã¨ããè¤æ°ã®è²¬åããããã¨ã«ã俺ã¯é·ãéæ°ã¥ããªãã£ããããã«æ°ã¥ããªãã¨ãåç¶æ¿ã¨å®è£ ç¶æ¿ãé ã®ä¸ã§æ´çã§ããªãã 西尾泰å(nishio.hirokazu): åãæè¿æ°ã¥ãããã¨ãå ããã¨ãã¯ã©ã¹ã«ã¯ãã¦ã¼ã¶å®ç¾©åããã¤ã³ã¹ã¿ã³ã¹ãä½æããéå ·ããå®è£ ã®åå©ç¨ã®åä½ãã¨ãã3ã¤ã®å½¹å²ãããã MIYAMOTO Daisuke: ãããã¤ã³ã¹ã¿ã³ã¹ã®çæå¨ãã 西尾泰å(nishio.hiroka
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}