Re: [問題] 如何再送參數到method?
※ 引述《Esh ()》之銘言:
: 換這個範例問可能比較單純
: input = ARGV[0]
: def somemethod(value="#{input}")
^^^^^^^^^^
這樣做根本沒有意義,因為你所想要的 input 本來就是字串
把字串轉成字串是多此一舉
此外,input 是 top level 的 local variable,
這樣寫看不到。既然 input 是 ARGV[0], 何不直接寫 ARGV[0] ?
--
#!/usr/bin/env ruby [露比] /Programming (Kn|N)ight/ 看板《Ruby》
# if a dog nailed extra legs that http://www.ptt.cc/bbs/Ruby/index.html
# walks like an octopus, and Welcome ~Ruby@ptt~
# talks like an octopus, then ◢█◣ http://www.ruby-lang.org/
# we are happy to treat it as █ http://www.ruby-doc.org/
# if it were an octopus. ◥ ◤ http://www.rubyforge.org/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.128.121.85
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 4 之 5 篇):
Ruby 近期熱門文章
PTT數位生活區 即時熱門文章