A+B: Difference between revisions
Content added Content deleted
(Add GDScript) |
(→{{header|GDScript}}: Simplified to only do one line to properly match spec) |
||
Line 2,918: | Line 2,918: | ||
extends Node |
extends Node |
||
@ |
@export var input: String: |
||
set(value): |
set(value): |
||
input = value # Save the input field |
input = value # Save the input field |
||
⚫ | |||
# 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 |
|||
⚫ | |||
output = "" |
|||
for part in parts: |
|||
sum += int(part) |
|||
out.append(str(sum)) |
|||
@export var output: String |
|||
output = "\n".join(out) |
|||
@export_multiline var output: String |
|||
</syntaxhighlight> |
</syntaxhighlight> |
||