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 #!/usr/bin/env ruby
class Test def digits(num)
def initialize(fruit) result = []
@fruit = fruit 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
end
result
end end
def hello num = 123
name = "Bob" puts digits(num)
puts "Hello #{name} !"
end
def eat # Additionner avec > que lui puis donner la somme
puts "#{@fruit}" # 1 + 2 = 3
end # 1 + 3 = 4
end # 2 + 3 = 5