rubyµÄÀàÓëÄ£¿é£¨1£©
class Point
@x = 1
@y = 2
def initialize(x,y)
@x,@y = x,y
end
end
´úÂëÖеÄ@x£¬@yΪʵÀý±äÁ¿£¬ÊµÀý±äÁ¿Ö»¶ÔselfµÄ»·¾³Æð×÷Óã¬Òò´ËinitializeÍâÃæµÄ@x=1£¬@y=2Ö»¶ÔÀà±¾ÉíÆð×÷Ó㬶ø·½·¨ÄÚ²¿£¬µÄ@x£¬@yÊǶԶÔÏóµÄʵÀýÆð×÷Óõġ£
class Point
include Enumerable
def initialize(x,y)
@x,@y = x,y
end
def each
yield @x
yield @y
end
end
puts Point.new(1,0).all? {|x|x==0}
ÎÒÃÇÔÚÀàÀï¿ÉÒÔ¶¨ÒåÊý×é[]·½·¨£¬Ò²¿ÉÒÔ¶¨Òåeach·½·¨£¬¶¨ÒåÁËeach·½·¨£¬ÎÒÃǾͿÉÒÔ»ìÈëEnumerableÁË
ʹÓÃEnumerableµÄ20¶à¸ö·½·¨£¬ÀýÈçall£¿
class Point
include Enumerable
attr_accessor :x,:y
def initialize(x,y)
@x,@y = x,y
end
def each
yield @x
yield @y
end
def ==(o)
if o.is_a? Point
@x == o.x && @y ==o.y
else
false
end
end
def eql?(o)
if o.instance_of? Point
@x.eql?(o.x) && @y.eql?(o.y)
else
false
end
end
end
a = Point.new(1,2)
b = Point.new(1.0,2.0)
puts "1"+ a.eql?(b).to_s
puts "2" + a.==(b).to_s
½ÓÏÂÀ´Ìí¼Óeql? ºÍ==Á½¸ö·½·¨£¬¿´ÏÂÕâÁ½¸ö·½·¨ÓÐʲô²»Í¬
eql?ÊǸüΪÑϸñµÄÏàµÈ£¬ÊDz»×öÀàÐÍÅжϵÄ
Ïà¹ØÎĵµ£º
To get it done is not easy. I spent a whole day to figure out the various compatibility issues along the way out.
Now there still might be potential issues, but it works by my rough test.
Step 1: Install Apache Cassandra
You may know that the Ruby gem cassandra will do it for you.
  ......
ѧÁËÒ»¸öѧÆÚµÄCÓïÑÔ£¬¿´ÁËÒ»¸öÐÇÆÚµÄruby£¬ÎҲŷ¢ÏÖΪʲôÀÏʦ˵CÊÇ×î»ù´¡µÄ£¬¼ÙÈçûÓÐÒ»¸öѧÆÚµÄC»ù´¡£¬ÄÇrubyÎÒÒ²²»Óÿ´ÁË¡£
RubyºÍCÓïÑÔÓÐÐí¶àµÄÏàͬµãºÍ²»Í¬µã£¬ÔÚѧϰrubyʱ£¬ÓÐʱ¿ÉÒÔÓÃCÀïÃæµÄ˼άÀ´Àí½â£¬¾ÍÏñrubyÀïÃæµÄ·½·¨Æäʵ¾Í¸úCµÄº¯ÊýÈç³öÒ» ......
ת Adding Sound to Your Ruby Apps
Have you ever thought about including sounds in your Ruby application? Used sparingly, sound may enhance your applications by adding audio cues or a custom touch. You could, for example, play a beep or chime that announces the completion of a lengthy process. Per ......
¡¡×î½ü£¬ÎÒÐèÒªÒ»ÖÖ¿ìËÙ¿ª·¢ÓïÑÔ£¬Ä¿Ç°ÖËÊÖ¿ÉÈȵĿìËÙ¿ª·¢ÓïÑÔ¾ÍÊÇPythonºÍRubyÁË¡£RubyºÍPython¶¼ÊǷdz£ÓÅÐãµÄ½Å±¾ÓïÑÔ£¬ËäÈ»ËûÃǵÄÉè¼ÆÕÜѧ¼¸ºõÍêÈ«²»Í¬£¬µ«ËûÃÇЧÂʲ¶à£¬Ó¦ÓÃÁìÓòÒ²²î¾à²»´ó£¬ËƺõÌìÉú¾ÍÊǾºÕù¶ÔÊÖ¡£µ½µ×Ñ¡ÄǸöÄØ?ÎÒ×öÁËһЩ¼òµ¥µÄ±È½Ï¡£
¡¡¡¡ÎÒÃDZȽ ......
1.1.Rails
1.1 ´´½¨Ò»¸öRailsÓ¦ÓóÌÐò
$ rails app_name
¿ÉÑ¡Ïî:
-d, database=xxx Ö¸¶¨°²×°Ò»¸öÊý¾Ý¿â(mysql oracle postgresql sqlite2 sqlite3 ), ĬÈÏÇé¿öÏÂÊÇÊý¾Ý¿â
-r, ruby-path= Ö¸¶¨RubyµÄ°²×°Â·¾¶,Èç¹ûûÓÐÖ¸¶¨£¬scriptsʹÓÃenvÈ¥ÕÒRuby
-f, freeze (¶³½á)freezes RailsÔÚvendor/railsĿ¼
1.2 API Docume ......