Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Rubyѧϰ±Ê¼ÇËÄ——Ä£¿é


#Ò»¡¢Ä£¿é¶¨Òå¼°ÒýÓã¬Ä£¿é¾ÍÊÇÒ»¶Î´úÂ룬ÀïÃæÓÐһЩ·½·¨·ÅÒ»Æð¡£
#¶¨ÒåÄ£¿éÓÃmodule...end ¡£Ä£¿éÓëÀà·Ç³£ÏàËÆ£¬µ«ÊÇ£º
#A) Ä£¿é²»¿ÉÒÔÓÐʵÀý¶ÔÏó£»
#B) Ä£¿é²»¿ÉÒÔÓÐ×ÓÀà¡£
include Math
puts sqrt(91);
module Me
  def sqrt(a)
  puts a*a;
  return a*a;
end
PI=3.1415926
end
include Me
puts sqrt(10)
puts Math.sqrt(10);
puts Math::PI;
puts Me::PI;#±äÁ¿ÒýÓÃÓë·½·¨µ÷Óò»Í¬£¬ÓÃ˫ðºÅ£¬¶ø²»ÊǵãºÅ
#¶þ¡¢¿É±ä²ÎÊý
def params(*num)
"This is text sqrt. "
puts num.size
puts num[1]
puts num.inspect
end
params(4,2,3)
#Èý¡¢Ä£¿éµÄµÚÈý¸ö×÷Óã¬ÊµÏÖÀàËÆÓÚ¶àÖØ¼Ì³ÐµÄ¹¦ÄÜ£¬Ò²³ÆMix-in
#ÎÒÃÇÓÐÒ»¸öStudentÀ࣬ÓÐ×ÅPersonÀàµÄÊôÐԺͷ½·¨£¬»¹»á×öÊýѧÌâ——Ç󯽷½¸ù¡£ÒѾ­ÓÐÁËMeÄ£¿é£¬Ö»ÒªMix-in ÔÚStudentÀàÀï¾Í¿ÉÒÔÁË¡£
module Me
  def sqrt(num, rx=1, e=1e-10)
    num*=1.0
    (num - rx*rx).abs <e ? rx : sqrt(num, (num/rx + rx)/2, e)
  end
end
class Person
  def talk
    puts "I'm talking."
  end
end
class Student < Person
  include Me
end
aStudent=Student.new
aStudent.talk # I'm talking.
puts aStudent.sqrt(20.7,3.3) # 4.54972526643248
#ͨ¹ý“ < ¸¸ÀàÃû ” £¬Ò»¸ö×ÓÀà¿ÉÒԵõ½¸¸ÀàµÄÊôÐԺͷ½·¨£»Í¨¹ý“ includeÄ£¿éÃû ” £¬Ò»¸ö×ÓÀà¿ÉÒԵõ½Ä³¸öÄ£¿éµÄ³£Á¿ºÍ·½·¨¡£À಻Äܱ» include ¡£
#ËÄ¡¢extend,»ìÐ͵ÄÁíÒ»ÖÖÇé¿ö
module Me
  def sqrt(num, rx=1, e=1e-10)
    num*=1.0
    (num - rx*rx).abs <e ? rx : sqrt(num, (num/rx + rx)/2, e)
  end
end
class Student
end
aStudent=Student.new
aStudent.extend(Me)
puts aStudent.sqrt(93.1, 25) # 9.64883412646315
#include ·½·¨ÎªÒ»¸öÀàµÄËùÓжÔÏó°üº¬Ä³¸öÄ£¿é£» extend ·½·¨ÎªÒ»¸öÀàµÄij¸ö¶ÔÏó°üº¬Ä³¸öÄ£¿é¡£
#Îå¡¢requireºÍload
#require£¬loadÓÃÓÚ°üº¬Îļþ£»include£¬extendÔòÓÃÓÚ°üº¬Ä£¿é¡£
#require¼ÓÔØÎļþÒ»´Î£¬load¼ÓÔØÎļþ¶à´Î¡£
#require¼ÓÔØÎļþʱ¿ÉÒÔ²»¼Óºó׺Ãû£¬load¼ÓÔØÎļþʱ±ØÐë¼Óºó׺Ãû¡£
#requireÒ»°ãÇé¿öÏÂÓÃÓÚ¼ÓÔØ¿âÎļþ£¬¶øloadÓÃ


Ïà¹ØÎĵµ£º

PythonºÍRubyµÄ¶Ô±È£¬¾ÀÕýһЩÎó½â

PythonºÍRubyµÄ¶Ô±È£¬¾ÀÕýһЩÎó½â
ÏÂÃæÊÇÎÒÔÚ¿´Á½Æª¹ØÓÚPythonºÍRuby¶Ô±ÈµÄÎÄÕÂʱ£¬Ëù×÷µÄ¾ÀÕý£¬Ô­ÎͼÊǹ㷺Á÷Ðеģ¬±È½ÏºÃÕÒ¡£
------------------------------------------------------
¡¶rubyºÍpythonµÄ±È½Ï¡·¸üÕýÒ»µãÊÂÇé
1¡¢Îĵµ¡¢¿ªÔ´ÏîÄ¿¡¢¿âÖ§³Ö£¬ÕâЩ¶«Î÷Ruby²»Òª¸úPython±È£¬²»ÊǼ¸¸öÊýÁ¿¼¶µÄÎÊÌ⣬ºÎ±ØÃ²Ë ......

ruby£º²é¿´°æ±¾£¬ÃüÁîÐÐÔËÐгÌÐò


Ô­ÎÄÁ¬½Ó£º http://hi.baidu.com/%B7%CF%B2%C5%CB%FB%B8%E7/blog/item/09c19411244152daf7039ec4.html
ͨ¹ýÃüÁîÐв鿴ruby°æ±¾ÐÅÏ¢£º
ruby -v
ÃüÁîÐÐÔËÐгÌÐò£º
·½·¨1.
ruby -e 'print "hello ruby"'
-e ±íʾ½«ºóÃæµÄÒ»ÐÐ×÷Ϊruby³ÌÐò
print ÊÇrubyµÄÒ»¸öÄÚÖú¯Êý
·½·¨2.½»»¥±àÒë»·¾³
irb £¨ÃüÁîÐÐÊäÈëºó£¬ ......

Ruby Ò»²½²½°²×°


http://www.gayathri-frenzy.com/technology/ruby-on-rails
I kept thinking for a while on what do I have next in the store
Here we go “Ruby on Rails”
Ruby on Rails, often shortened to Rails or RoR, is an open source web application framework for the Ruby Programming language.Ruby is a ......

win»·¾³Ï±¾µØ°²×°ruby on rails

ÎÄÕÂת×Ô http://www.ej38.com/showinfo/Ruby-140367.html 
¹ý³ÌÈçÏ£º
1¡¢rubyÏÂÔØÒ»¼ü°²×°£º
http://rubyforge.org/frs/download.php/29263/ruby186-26.exe
ruby -v ÏÔʾ°æ±¾£¬°²×°³É¹¦
2¡¢ÏÂÔØrubygems°²×°£º
http://rubyforge.org/frs/download.php/60719/rubygems-1.3.5.zip
½âѹ£¬ruby setup.rb
g ......

ruby on rails ½â¾ömultiple select ´æ´¢ºÍupdate

²Ù×÷ϵͳubuntu£¬¿ª·¢¹¤¾ßnetbeans
vendorÊý¾Ý¿â±íÓÐ×Ö¶Îservice_category varchar(100)
<% form_for :vendor, @vendor, :url => sellers_path do |f| %>
  <%= f.select(:service_category,
                  ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ