é©ãã¾ããã rubycoï¼ãã³ãï¼ã®æ¥è¨ - ããã©ã«ãå¼æ°ã¯æ示çã«è©ä¾¡ãããã¨åããã¨ãPythonã§æ¸ããå ´åãé¢æ°å®ç¾©ã®æç¹ã§è©ä¾¡ããã¾ãã >>> def default(n): print "default", n return n + 1 >>> def foo(x, y = default(5)): print x, y default 5 Rubyã§ã¯é¢æ°ãå¼ã°ããæã«ããã©ã«ãå¼æ°ãè©ä¾¡ããããã§ãããããé 延è©ä¾¡ã¨ãã§ã¯ãªãããã§ãä½åº¦ãé¢æ°ãå¼ã¹ã°ä½åº¦ãå®è¡ããã¾ããã¤ã¾ãPythonã§æ¸ãã° >>> def foo(x, y = None): if y == None: y = default(5) print x, y ã«ç¸å½ããç¶æ ã®ããã§ãã
{{#tags}}- {{label}}
{{/tags}}