This commit is contained in:
julien committed 2026-10-14 15:44:34 +02:00
1 parent 0980afcc33
commit 1bf550a752
1 file changed
+16 -11
+16 -11
View File
@@ -1,16 +1,21 @@
#!/usr/bin/env ruby
class Test
def initialize(fruit)
@fruit = fruit
def digits(num)
result = []
numbers = num.to_s.split('').map { |n| n.to_i }
numbers.each_with_index do |number, index|
following = numbers[(index + 1)..]
following.each do |other|
result << number + other
end
def hello
name = "Bob"
puts "Hello #{name} !"
end
def eat
puts "#{@fruit}"
end
result
end
num = 123
puts digits(num)
# Additionner avec > que lui puis donner la somme
# 1 + 2 = 3
# 1 + 3 = 4
# 2 + 3 = 5