Skip to content

Instantly share code, notes, and snippets.

@muhammadyana
Last active June 8, 2017 08:50
Show Gist options
  • Save muhammadyana/cba7003c5f162065c192263e20638792 to your computer and use it in GitHub Desktop.
Save muhammadyana/cba7003c5f162065c192263e20638792 to your computer and use it in GitHub Desktop.
File size, next, break and redo
def cool_dude(arg1="Miles", arg2="Coltrane", arg3="Roach")
"#{arg1}, #{arg2}, #{arg3}."
end
p cool_dude
p cool_dude("Bart")
p cool_dude("Bart", "Elwood")
p cool_dude("Bart", "Elwood", "Linus")
file = File.size("regex.rb")
p File.size("regex.rb")
p Math.sin(Math::PI/4)
b = 2
a = file.hash
puts "Hasil hash adalah = #{a}"
#
# def tes
# "one"
# end
#
# p tes
def meth_three
100.times do
|num|
square = num*num
#puts square
return num, square if square >1000
end
end
# puts "hasil dari meth_three = #{meth_three}"
# num, square = meth_three
# puts "hasil dari num = #{num}"
# puts "Square = #{square}"
# puts "(t)imes or (p)lus: "
# operator = gets
# puts "number: "
# number = Integer(gets)
# if operator =~ /^t/
# puts((1..10).collect {|n| n*number }.join("- "))
# else
# puts((1..10).collect {|n| n+number }.join("- "))
# end
# while line = gets
# puts line
# end
# for i in ['fee', 'fi', 'fo', 'fum']
# print i, " "
# end
while line = gets
next if line =~ /^\s*#/
break if line =~ /^END/
redo if line.gsub!(/`(.*?)`/){
eval($1)
}
end
i = 0
loop do
i += 1
next if i < 3
print i
break if i>=10
end
puts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment