Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error in cell 12 of 1_intro_to_scala #49

Closed
lomax opened this issue Nov 14, 2018 · 2 comments
Closed

Compilation error in cell 12 of 1_intro_to_scala #49

lomax opened this issue Nov 14, 2018 · 2 comments

Comments

@lomax
Copy link

lomax commented Nov 14, 2018

I'm getting an error trying to run code in the cell number 12 in the notebook:

val randomList = List(util.Random.nextInt(), util.Random.nextInt(), util.Random.nextInt(), util.Random.nextInt())
var listSum = 0
for (value <- randomList) {
  listSum += value
}
println("sum is " + listSum)

error is:
cmd17.sc:1: object Random is not a member of package ammonite.util val randomList = List(util.Random.nextInt(), util.Random.nextInt(), util.Random.nextInt(), util.Random.nextInt()) ^cmd17.sc:1: object Random is not a member of package ammonite.util val randomList = List(util.Random.nextInt(), util.Random.nextInt(), util.Random.nextInt(), util.Random.nextInt()) ^cmd17.sc:1: object Random is not a member of package ammonite.util val randomList = List(util.Random.nextInt(), util.Random.nextInt(), util.Random.nextInt(), util.Random.nextInt()) ^cmd17.sc:1: object Random is not a member of package ammonite.util val randomList = List(util.Random.nextInt(), util.Random.nextInt(), util.Random.nextInt(), util.Random.nextInt()) ^Compilation Failed Compilation Failed

According to the Coursier log i should have
https://repo1.maven.org/maven2/com/lihaoyi/ammonite-util_2.11/1.2.1-12-bc459e3/ammonite-util_2.11-1.2.1-12-bc459e3.pom 100,0% [##########] 1,9 KiB (11,0 KiB / s)
installed as a dependency for almond.

@lomax lomax changed the title Compilation error in cell 17? of 1_intro_to_scala Compilation error in cell 12 of 1_intro_to_scala Nov 14, 2018
@lomax
Copy link
Author

lomax commented Nov 14, 2018

And after i added import scala.util once in this cell the issue dissapeared.
So by default it were looking for util.Random inside ammonite package and after i executed import scala.util just once it start to search inside the standard scala library.

grebe added a commit that referenced this issue Feb 18, 2019
@grebe
Copy link
Contributor

grebe commented Feb 18, 2019

Thanks for pointing this out!

edwardcwang pushed a commit that referenced this issue Feb 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants