.. VS … # Range titik titik VS titik titik titik

Posted: April 20, 2007 in RUBY

Perhatikan irb yang ke 016. Lima tidak termasuk dalam objek Range, alias isinya cuma 1, 2, 3, sampai empat.

irb(main):013:0> a = 1..5
=> 1..5
irb(main):014:0> b = 1...5
=> 1...5
irb(main):015:0> a.include?(5)
=> true
irb(main):016:0> b.include?(5)
=> false
irb(main):017:0> za = [1,2,3,4,5]
=> [1, 2, 3, 4, 5]
irb(main):019:0> za.pop
=> 5
irb(main):020:0> za
=> [1, 2, 3, 4]
irb(main):025:0> b.to_a == za
=> true
irb(main):026:0> 
Comments
  1. irfani says:

    the ruby wayyy….

tinggalkan feedback konstruktif atau lebih baik diam

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s