0

As a beginner in programming and learning Processing,I am really stuck on this. Probably as simple as it can be but I don't see it anymore. What am I doing wrong?

int geefCijfer (int[] cijfer1) {
  String [] cijfers =loadStrings("cijfers_klein.txt");
  int [] cijfer = new int [cijfers.length];
  for (int i = 0; i< cijfers.length; i++) {
    cijfer[i] = int(cijfers[i]);
    println(cijfer);
  } 
  return cijfer;
}
1
  • Can you please be more specific? What do you expect this code to do? What does it do instead? Can you please post a minimal reproducible example? Commented Mar 6, 2018 at 17:15

1 Answer 1

0

In the future, please try to be more specific. Include in your question what you expect the code to do, what it does instead, and a MCVE that demonstrates the problem.

That being said, I copied your code into my Processing editor and I get a compiler error on this line:

return cijfer;

The error says:

Type mismatch: cannot convert from int[] to int

This is happening because you're returning cijfer, which is an int[] type, but you've declared your function to return an int. You either need to change what you're returning, or change the return type of the function. My guess is you just want to change the return type:

int[] geefCijfer (int[] cijfer1) {

This gets rid of the error, but you'll still have a warning because you never use the cijfer1 variable. That won't prevent you from running your code, but it's probably something you want to think harder about.

Also note that instead of manually converting each index of the array, you can pass the whole array into the int() function:

String [] cijfers =loadStrings("cijfers_klein.txt");
int [] cijfer = int(cijfers);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.