因为每个人都在他们的代码中使用irb(main):001:0> ;-)这是基于我们学校老师一直使用void main(),...
rawdownloadcloneembedprintreport irb(main):001:0>a ={id:1} =>{:id=>1} irb(main):002:0>[*a] =>[[:id,1]] irb(main):003:0>[a] =>[{:id=>1}] irb(main):004:0> Advertisement Ad Add Comment Please,Sign Into add comment Advertisement Ad...
irb(main):001:0>array1=[1,2,3,4,5]=>[1,2,3,4,5]irb(main):002:0>array2=[3,4,5,6,7]=>[3,4,5,6,7]irb(main):003:0>matching_items=array1&array2=>[3,4,5]irb(main):004:0>puts matching_items345=>nil 在上述示例中,我们创建了两个数组array1和array2,然后使用&运...
irb(main):003:0*4 =>7 irb(main):004:0> puts"me".capitalize Me =>nil irb(main):005:0> exit d:\> 其中的“irb(main):001:0>”是默认的irb提示符,可以选择不同的风格或自定义。提示符中irb表示会话名称,(main)表示会话的顶级对象;如果在irb中启动子会话,可以传入不同的对象最为顶级对象,则提...
irb(main):001:0> x = 10 => 10 irb(main):002:0> y = 20 => 20 irb(main):003:0> sum = x + y => 30 irb(main):004:0> sum * 2 => 60 irb(main):005:0> exit $ “` 上面的例子展示了使用IRB执行简单的加法计算,并查看计算结果的过程。在第一行代码中,定义了变量x,并赋值为10...
irb#2(another):001:0> jobs => #0->irb on main (#<Thread:0x34cc748>: stop) #1->irb#1 on main (#<Thread:0x3a49e8c>: stop) #2->irb#2 on another (#<Thread:0x3a43a78>: running) irb#2(another):002:0> fg 1 => #<IRB::Irb: @signal_status=:IN_EVAL, @scanner=#<Ruby...
hello.rb(main):001:0> #!/usr/bin/env ruby hello.rb(main):002:0* hello.rb(main):003:0* class Hello hello.rb(main):004:1> def initialize( hello ) hello.rb(main):005:2> @hello=hello hello.rb(main):006:2> end hello.rb(main):007:1> def hello ...
irb(main):001:0> elvuel="elvuel" => "elvuel" irb(main):002:0> elvuel.class => String 可以通过exit 或 quit,或者通过输入一个文件结束符号(如果没有设置IGNORE_EOF模式)来退出irb. 在一个irb会话中,你所设置的变量、定义的方法及创建的类都将被记忆在irb的工作区中,并可被后续使用。
irb(main):001:0> The prompt indicates that you’re running IRB and that anything you execute will run in themaincontext, which is the top-level default context of a Ruby program. It also shows a line number. Note: If you’ve installed Ruby with RVM, your prompt may look slightly diffe...
irb(main):001:0>1 + 1 2 irb(main):002:0>def t(x) irb(main):003:1>x + 1 irb(main):004:1>end => :t irb(main):005:0>t(3) => 4 irb(main):006:0>ift(3) == 4 irb(main):007:1>p :ok irb(main):008:1>end ...