⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 15 - redirecting standard input or output.rb

📁 O Reilly Ruby Cookbook source code
💻 RB
字号:
#!/usr/bin/env ruby# redirect_stdout.rbrequire 'stringio'new_stdout = StringIO.new$stdout = new_stdoutputs 'Hello, hello.'puts "I'm writing to standard output."$stderr.puts "#{new_stdout.size} bytes written to standard ouput so far."$stderr.puts "You haven't seen it on the screen yet, but you soon will:"$stderr.puts new_stdout.string#---$ ruby redirect_stdout.rb46 bytes written to standard output so far.You haven't seen it on the screen yet, but you soon will:Hello, hello.I'm writing to standard output.#---

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -