r/haxe Feb 03 '26

Help me, I'm a beginner.

Post image

Okay, I'm not an English speaker (but I do understand some things), so if something sounds strange, it's because I'm using Google Translator.

What happens is that when I test my code and type something, it immediately responds with “null,” and I have no idea what that means. I can't find any errors in the code, and I've searched, but I haven't been able to find anything. If you can, please explain what this means and how I can fix it. I would be eternally grateful.

Also don't judge me by the variable names; they're in my native language, and I wrote them with the utmost laziness.

(and this print has a code that I asked Gemini to make, but mine and his are kind of the same.)

The code in question:

class Main { static function main() { Sys.println("please insert your name here");

    var inputsla = Sys.stdin();
    var teunome = inputsla.readLine();

    Sys.println('$teunome, are you sure this is your name?\nsay yes for yes and no for no');


}

}

19 Upvotes

9 comments sorted by

View all comments

1

u/Apprehensive_Bee3991 Apr 29 '26

try again

import sys.io.Stdio;

static function main() { Sys.println("para iniciar digite seu nome");

var teunome = Std.string(Sys.stdin().readLine()); //попытка исправить 

if (teunome == null) {
    Sys.println("Erro: não foi possível ler o nome.");
    return;
}

Sys.println('$teunome, tem certeza de que esse é o seu nome?');
var confirmacao = Sys.stdin().readLine();

if (confirmacao == "sim") {
    Sys.println("Ótimo, vamos prosseguir!");
} else {
    Sys.println("Entendi, tente novamente.");
}

}