https://kotlinlang.org logo
#announcements
Title
# announcements
m

mike_shysh

10/30/2017, 2:05 PM
The ways I know is to parse yaml into the Object, but I need only Map<String, int>
d

diesieben07

10/30/2017, 2:11 PM
Copy code
val map = file.split(Regex("[\r\n]+"))
    .filterNot { it.startsWith('#') }
    .map { it.split('=', limit=2).map(String::trim) }
    .map { it[0] to it[1] }
    .toMap()
m

mike_shysh

10/30/2017, 4:08 PM
Thanks
d

diesieben07

10/30/2017, 4:10 PM
Can probably be optimized, but that's the general idea
3 Views