2015-05-04

Ruby : General Delimited Input

這邊...是邪惡的開始||||

from : http://ruby-doc.org/docs/ruby-doc-bundle/ProgrammingRuby/book/language.html

其中只解釋


  %q = '' Single-quoted string
  %Q, % = "" Double-quoted string
  %w = [] Array of tokens (split by ' ')
  %r = // Regular expression pattern
  %x = `` Shell command


後面還寫了,此標記後面一碼為包圍碼除了[0-9A-Za-z],所以以下都是合用的


  %q!\n!   #=>  "\\n"
  %?\n?    #=>  "\n"
  %w%123 234% #=> ["123","234"]
  %r/test/  #=> /test/
  %r\test\  #=> /test/
  %x.ls.    #=> call system `ls`
  %x#ls#    #=> call system `ls`
  %!%!      #=> '%'
  ...


嘛...寫code要小心了X"D或是小心別人的code

沒有留言:

張貼留言