[Solved] Barrier to learning programming -- Learning how to use docs

This is true for many languages I’ve looked at: If there are no example cases then I’m totally lost. I’ve even googled how to read docs and there is very little help.

So as a quick example, I want to do this:

class Test {
static function main() {
trace("Enter a number between 1 and 10: ");
var entry = Sys.stdin().readLine();
// Parse string to number and place into [new?] variable
var newEntry = ???

According to the doc API’s I am lead to the Std page:
static parseInt (x:String):Null<Int>

How do you know what needs to be typed, what needs to be replaced, and what is there for information only.

  1. First, look at the API page that your code example falls into. In this example it’s “Std” class without the quotes.
  2. Then add a dot “.”
  3. “Static” is information. It is not typed.
  4. “parseInt” is the method. Type without quotes.
  5. Opening parenthesis.
  6. Place your string in quotes or your variable that has string information. Replace “x:String” (expected input) completely.
  7. Closing parenthesis
  8. Everything to the right, including the “:”, is information (expected output) and is not to be typed.

So the final method looks like this

If you want it to do something useful, assign it to a new variable:
var newEntry = Std.parseInt(entry);

You might want to check out the beginner section on the code cookbook.

It has this article which demonstrates how you can deal with numbers: