Skip to content

Instantly share code, notes, and snippets.

View boddhisattva's full-sized avatar
🌷
Vasudhaiva Kutumbakam 🙂

Mohnish G J boddhisattva

🌷
Vasudhaiva Kutumbakam 🙂
View GitHub Profile
@boddhisattva
boddhisattva / sample_markdown_file.md
Last active August 27, 2015 11:36
A sample markdown file to help explain the advantages of using markdown syntax
puts "hi"

a = [4,3,2]

a.each do |each_argument|
  puts each_argument
end
@boddhisattva
boddhisattva / Hashes
Last active August 29, 2015 13:56
Hashes in Ruby
Total Months via hashes: 8
#{numbers["two"]}
zero
5
@boddhisattva
boddhisattva / Arrays
Last active August 29, 2015 13:56
Arrays in Ruby
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
@boddhisattva
boddhisattva / Hello World in Ruby
Created February 18, 2014 22:22
Helloworld program - Ruby
Hello World
@boddhisattva
boddhisattva / numbers in ruby
Last active August 29, 2015 13:56
Playing with numbers in Ruby
20
6
50
Subtraction of 50 - 30 is: 20
Exponentiation of 3^3 is: 27
Value of 5 modulo 3 is: 2
@boddhisattva
boddhisattva / User input in ruby.rb
Last active August 29, 2015 13:56
Taking User input in Ruby
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
@boddhisattva
boddhisattva / Operators1.rb
Last active August 29, 2015 13:56
Operators in Ruby - Part 1
# Playing with operators in Ruby
limit = 5
p = 2 * Math.sqrt(4) < limit
puts(p)
k = 2 ** 4 # Exponentiation Operator..
puts(k)
@boddhisattva
boddhisattva / Operators2.rb
Created February 19, 2014 05:37
Operators in Ruby - Part 2
# Equality operators( '==' and check this '==='( case equality operator.. do note.. ) ).
a1 = 3
a2 = 4
a3 = 0
s1 = (a1==a2)
puts(s1)
s2 = (a3!=a2)
@boddhisattva
boddhisattva / conditionals.rb
Created February 19, 2014 05:43
Conditionals in Ruby
# Conditionals
a = 5
b = 3
# if else in operation..
if a < b
puts("true")
else
@boddhisattva
boddhisattva / iterators.rb
Last active August 29, 2015 13:56
Iterators in Ruby
# 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..