Last active
June 8, 2017 04:19
-
-
Save muhammadyana/c2eb47ddccb0fdf49e6135c48db0ba4e to your computer and use it in GitHub Desktop.
Standar Type in Ruby
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
#thursday-08-2017 | |
#@41studio | |
#Muhammad Yana Mulyana | |
#mixins in ruby | |
puts "Enter count of loop " | |
lp = gets.chomp.to_i | |
puts "Enter value to calculate " | |
val = gets.chomp.to_i | |
num = val | |
lp.times do | |
puts "This is #{num.class}: #{num}" | |
num *= num | |
end | |
b = Rational(3, 4) * Rational(2, 3) #ambil kpk | |
puts "hasil B adalah #{b} " | |
complex = Complex(1, 2) * Complex(3, 4) | |
puts complex | |
# word = "Hallo Word" | |
# puts word.split | |
lp.upto(val) do | |
|x| | |
puts "Upto from #{lp} to #{val} is = #{x}" | |
end | |
val.downto(lp){ | |
|a| | |
puts "Downto From #{val} to #{lp} is = #{a}" | |
} | |
50.step(80, 5) {|i| print i, " " } | |
puts | |
#puts string | |
puts %q/ Hallo my name is joh doe/ | |
puts %{this is print with %{}} | |
puts %!This is print with %! | |
p digits = lp..val | |
puts digits.include?(9) | |
puts digits.inject(:+) | |
case lp | |
when lp..5 | |
puts "That right " | |
else | |
puts "Not belong" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment