SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. val numbers = doubleArrayOf(4.41, 6.399999, 12.0, 14.46, 17.171717171)
  2.        
  3. println("Straight join: ${numbers.joinToString()}")
  4. //Straight join: 4.41, 6.399999, 12.0, 14.46, 17.171717171
  5.  
  6. println("Specifying separator: ${numbers.joinToString(separator = " ~ ")}")
  7. //Specifying separator: 4.41 ~ 6.399999 ~ 12.0 ~ 14.46 ~ 17.171717171
  8.  
  9. println("Specifying prefix and suffix: ${numbers.joinToString(prefix = "{", postfix = "}")}")
  10. //Specifying prefix and suffix: {4.41, 6.399999, 12.0, 14.46, 17.171717171}
  11.  
  12. println("Limiting number of elements: ${numbers.joinToString(limit = 3)}")
  13. //Limiting number of elements: 4.41, 6.399999, 12.0, ...
  14.  
  15. println("Limiting number of elements And setting truncate: ${numbers.joinToString(limit = 3, truncated = "etc.")}")
  16. //Limiting number of elements And setting truncate: 4.41, 6.399999, 12.0, etc.
  17.  
  18. println("Rounding using transform(): ${numbers.joinToString(transform = {round(it).toString()})}")
  19. //Rounding using transform(): 4, 6, 12, 14, 17
  20.  
  21. println("Specifying everything: ${numbers.joinToString(separator = " ~ ", prefix = "{", postfix = "}", transform = {round(it).toString()}, limit = 3, truncated = "etc.")}")
  22. //Specifying everything: {4 ~ 6 ~ 12 ~ etc.}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top