JavaScript has bracket notation for objects that allows you to access properties using variables like so:
let x = {name : 'John', age: 21};
let y = 'age'
console.log(x[y])
//21
Is there an equivalent to this for accessing properties in class objects (get all variables in a class instance) in Scala 2?