You can technically do this with reflection, but you shouldn't.
class Foo {
val foo0 = 10
val foo1 = 5
}
val r = new scala.util.Random
scala> val foo = new Foo
foo: Foo = Foo@f5009c7
scala> foo.getClass.getDeclaredMethod("foo" + r.nextInt(2)).invoke(foo).asInstanceOf[Int]
res19: Int = 10
Again, we shouldn't do this. It will turn your code into a sprawling mess of a minefield.
If you ever find yourself naming things with indices like foo0, foo1, foo2, etc, that means they probably belong in a collection of some type.
val foos = List(10, 5)
Then you can access them by index using apply:
foos.apply(r.nextInt(2))
scala> foos(r.nextInt(2))
res20: Int = 5