Posts by jsdaniell • 256 points
6 posts
-
2
votes1
answer1197
viewsQ: How to understand this structure?
ContactHelper.internal(); static final ContactHelper _instance = ContactHelper.internal(); factory ContactHelper() => _instance; After an intense research on Factory methods and Singleton…
-
4
votes1
answer224
viewsQ: How to add values to an array of a Ruby array?
puts "Alunos\n\n" alunos = [["Daniel: ", "Nota: 10\n\n"],["Abima: ", "Nota: 10\n\n"], ["Wilame: ", "Nota: 10\n\n"],["Felipe: ","Nota: 10\n\n"]] puts alunos I wonder if it is possible to add a new…
-
2
votes3
answers787
viewsA: Questions about activity diagrams
The activity diagram describes the sequence of activities involving software, showing from the user’s actions to the completion of software functions. In the above example I describe a simple…
-
3
votes1
answer200
viewsQ: What is the real need for the "initialize" method in Ruby?
def initialize(nome = "Anônimo", salario = 0.0) @nome = nome @salario = salario end To clarify, what I can’t understand is the difference between using this method in a class and for what purpose it…
-
1
votes1
answer170
viewsQ: How to use a method that is within a class and sums two numbers in Ruby
class Soma def somar(num1, num2) @num1 = num1 @num2 = num2 result = num1 + num2 puts "O resultado é #{result}" end end summing = sum.new (1, 2) I can’t understand why the following code doesn’t…
-
0
votes1
answer270
viewsQ: How to make calculations with elements of a Ruby array?
numeros = [1, 2] class C def calcule_array(*numeros) puts a + b end end numeros = C.new puts numeros I would like to know how to make calculations with whole elements that are inside an array in…