puts "hi"
a = [4,3,2]
a.each do |each_argument|
puts each_argument
end
This file contains 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
Total Months via hashes: 8 | |
#{numbers["two"]} | |
zero | |
5 |
This file contains 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
1 | |
6 | |
Using size(above) n length(below) properties to print no. of elements in a string | |
6 | |
tryin to print anything outside array bounds ..like value of a[8] prints nill.. do note.. | |
11 | |
note how through a[-3] we get the value of the third last element of the array 7 | |
changing value of 1st element of array to 25.. and printing it.. note the way its printed..25 | |
Dyanmically do note how the size of an array can be increased in Ruby..Making things simpler n Faster..and a programmer can't be happier.. Yukihiro Matsumto | |
value of a[6]: zero |
This file contains 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
Hello World |
This file contains 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
20 | |
6 | |
50 | |
Subtraction of 50 - 30 is: 20 | |
Exponentiation of 3^3 is: 27 | |
Value of 5 modulo 3 is: 2 |
This file contains 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
print('HI..!! enter ur name please: ') | |
name = gets() | |
puts("Hello #{name}") | |
#this symbol is mainly used for comments.. what role is it playing here..?? | |
# the hash symbol in the puts stmnt above within quotes can be used to print the value of the entity within the quotes | |
puts("\n") | |
#<<name |
This file contains 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
# Playing with operators in Ruby | |
limit = 5 | |
p = 2 * Math.sqrt(4) < limit | |
puts(p) | |
k = 2 ** 4 # Exponentiation Operator.. | |
puts(k) |
This file contains 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
# Equality operators( '==' and check this '==='( case equality operator.. do note.. ) ). | |
a1 = 3 | |
a2 = 4 | |
a3 = 0 | |
s1 = (a1==a2) | |
puts(s1) | |
s2 = (a3!=a2) |
This file contains 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
# Conditionals | |
a = 5 | |
b = 3 | |
# if else in operation.. | |
if a < b | |
puts("true") | |
else |
This file contains 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
# working with iterators | |
3.times { puts "thank you!" } | |
puts("\n") | |
data = [1,2,3,4,5] | |
data.each {|x| puts x} # note how x although its not being declared or defined.. works for each element of the array data.. |
OlderNewer