以下是Zed Shaw的一些代码:
formatter = "%{first} %{second} %{third} %{fourth}"
puts formatter % {first: 1, second: 2, third: 3, fourth: 4}
puts formatter % {first: "one", second: "two", third: "three", fourth: "four"}
puts formatter % {first: true, second: false, third: true, fourth: false}
puts formatter % {first: formatter, second: formatter, third: formatter, fourth: formatter}
puts formatter % {
first: "I had this thing.",
second: "That you could type up right.",
third: "But it didn't sing.",
fourth: "So I said goodnight."
}
Run Code Online (Sandbox Code Playgroud)
我明白这 …
我在 Google Drive 上有一些数据,组织在文件夹中,我想将它们传播到其他服务器上。我有一些用于传播的脚本,但我需要从谷歌驱动器下载数据。有没有一种通过 Google Drive API 下载文件夹的方法,同时还能维护整个文件夹结构?
Array#sample如果你通过一个范围作为随机数发生器,如何工作?在这里:
> [*1..10].sample(random: 1..3)
=>9
Run Code Online (Sandbox Code Playgroud) 我想为Integer类添加新方法,但我不知道如何在此方法中访问整数值:
class Integer
def foo
'foo' * value
end
end
Run Code Online (Sandbox Code Playgroud)
它应该像:
3.foo
=> 'foofoofoo'
Run Code Online (Sandbox Code Playgroud)