@kenanhancer/

rubyTest1

Ruby

No description

fork
loading
Files
  • main.rb
  • StringExtensions.rb
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require './StringExtensions.rb'

$global_variable = 10
puts "Global variable in Class1 is #$global_variable"

[1,2,3,4].each do |e|
    print "#{e} "
end



m = {"ruby" => "rails", "groovy" => "grails", "scala" => "lift", "java" => "spring"}
m.each do |lang, framework|
    # print the keys first - "ruby groovy scala java"
    print "#{lang} "
    # print the values second - "rails grails lift spring" 
    print "#{framework} "
end

stooges = ['Larry', 'Curly', 'Moe']
stooges.each { |stooge| print stooge + "\n" }

stooges.each do |stooge|
  print stooge
  print "\n"
end

contact_info = { 'name' => 'Bob', 'phone' => '111-111-1111' }
contact_info.each { |key, value| print key + ' = ' + value + "\n" }

contact_info.each do |key, value|
  print print key + ' = ' + value
  print "\n"
end


10.times do puts "Hello world" end

puts 3.14.class
puts true.class
puts Math.class
puts Math::PI.class
puts "Merhaba".class
puts 999999999999999999999999999999999999999999999999999999.class
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]