A+B: Difference between revisions

180 bytes removed ,  1 year ago
→‎{{header|GDScript}}: Simplified to only do one line to properly match spec
(Add GDScript)
(→‎{{header|GDScript}}: Simplified to only do one line to properly match spec)
Line 2,918:
extends Node
 
@export_multilineexport var input: String:
set(value):
input = value # Save the input field
 
var partsfields := linevalue.split(" ", false) # Split by spaces
# For every line of input, append the sum as a string to the out array.
if len(fields) == 2: # Basic input validation
var out: Array[String] = [] # Array to store the lines of output
output = str(int(fields[0]) + int(fields[1]))
for line in value.split("\n"):
else: # Invalid input
var parts := line.split(" ", false)
varoutput sum := 0""
for part in parts:
sum += int(part)
out.append(str(sum))
 
#@export Update thevar output: propertyString
output = "\n".join(out)
 
@export_multiline var output: String
</syntaxhighlight>
 
89

edits