This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| array=[1,2,3,4,5,6] | |
| puts array[2..4] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| array = ['junk', 'junk', 'junk', 'val1', 'val2'] | |
| 3.upto(array.length-1) { |i| puts "Value #{array[i]}" } #This is an example of Integer#upto | |
| array = ['1', 'a', '2', 'b', '3', 'c'] | |
| 0..array.length-1).step(2) do |i| # This is an example of Range#step | |
| puts "Letter #{array[i]} is #{array[i+1]}" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ['a','b','c'].each_with_index do |item,index| | |
| puts "At Position #{index} : #{item}" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a.collect! {|x| x**2} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| b=a.collect {|x| x**2} | |
| puts b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a=[23,45,576,12] | |
| a.each {|x| puts x} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Main file | |
| require "Twitter.rb" | |
| require 'json' | |
| require 'uri' | |
| Shoes.app :width=>300, :height=>400, :title=>"Rubydubee" do | |
| @twitter = Twitter.new "consumer_key", | |
| "consumer_secret" | |
| @main_stack = stack do |
NewerOlder