Skip to content
Advertisement

Unexpected type required variable found value

JavaScript

For some reason this code gives compilation Error ,could anyone explain why?

Advertisement

Answer

ToFill.get(Position) returns a value where the left-hand side of the assignment must be a variable. Instead, use set(index, element) as follows:

JavaScript

However, what you are doing is only valid if you are using arrays, for example:

JavaScript

As a side note, always use Java naming convention:

  • toFill instead of ToFill
  • alter instead of Alter
  • position instead of Position.
  • value instead of Value.
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement