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

Java to Scala sets #88

Open
Nithanaroy opened this issue Jun 22, 2018 · 0 comments
Open

Java to Scala sets #88

Nithanaroy opened this issue Jun 22, 2018 · 0 comments

Comments

@Nithanaroy
Copy link

Java Code:

private final static Map<String, String> props = new LinkedHashMap<String, String>();

final Set<String> propSet = props.keySet(); 
StringBuilder newString = new StringBuilder(); 

for (String prop : propSet) { 
    if (newString.length() > 0) { 
        newString.append("|"); 
    } 
    newString.append(prop); 
} 

On converting this code to scala, get an error on the line,
Scala Code

...
for (prop <- propSet) {
...

saying foreach does not exist for the class java.util.Set[String]. Had to convert it to Scala set using asScalaSet(propSet) as mentioned in https://alvinalexander.com/scala/how-to-go-from-java-collections-convert-in-scala-interact.

Being new to Scala not sure if this is actually a bug to be reported here

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

1 participant