• Save
Scala dreaded underscore
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Scala dreaded underscore

on

  • 20,154 views

A reference about every use cases of underscores in the Scala programming language

A reference about every use cases of underscores in the Scala programming language

Statistics

Views

Total Views
20,154
Views on SlideShare
20,114
Embed Views
40

Actions

Likes
33
Downloads
7
Comments
2

11 Embeds 40

http://www.redditmedia.com 13
http://proaction-development.com 9
https://twitter.com 4
http://www.pinterest.com 3
http://www.slideshare.net 2
https://si0.twimg.com 2
http://twitter.com 2
http://static.slidesharecdn.com 2
http://www.linkedin.com 1
http://a0.twimg.com 1
https://www.linkedin.com 1
More...

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial LicenseCC Attribution-NonCommercial License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • More Scala symbols and Idiomatic references & cheatsheets
    http://stackoverflow.com/questions/7888944/scala-punctuation-aka-symbols-operators
    http://www.reddit.com/r/scala/comments/lo3i4/scala_punctuation_help/
    http://www.slideshare.net/normation/scala-dreaded
    http://agileskills2.org/blog/2011/05/01/revealing-the-scala-magicians-code-expression/
    http://jim-mcbeath.blogspot.com/2008/09/scala-syntax-primer.html
    http://jim-mcbeath.blogspot.com/2008/12/scala-operator-cheat-sheet.html
    http://scalex.org/
    http://www.artima.com/pins1ed/book-index.html#indexanchor
    http://stackoverflow.com/questions/7656937/valid-identifier-characters-in-scala
    Are you sure you want to
    Your message goes here
    Processing…
  • well done
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Scala dreaded underscore Presentation Transcript

  • 1. Scala dreaded _ François Armand
  • 2. Too many use for _ ? © Normation 2010 - 2
  • 3. Too many use for _ ? © Normation 2010 - 3
  • 4. It's always a kind of joker 1/ “Everything” 2/ “Give me a variable name but – I don't care of what it is – and/or – don't want to pollute my namespace with it” © Normation 2010 - 4
  • 5. 1. Import all Java “import *” © Normation 2010 - 5
  • 6. 2. var initialization to default value Highly discourage in idiomatic Scala: – Prefer val against var – Try to always initialize a variable © Normation 2010 - 6
  • 7. 3. Unused variables In higher order functions © Normation 2010 - 7
  • 8. 3. Unused variables In pattern matching © Normation 2010 - 8
  • 9. 4. Anonymous parameters In higher order functions © Normation 2010 - 9
  • 10. 4. Anonymous parameters In partial functions © Normation 2010 - 10
  • 11. 5. Don't import name in namespace © Normation 2010 - 11
  • 12. 6. Syntactic sugar for existential type Existential type ? http://stackoverflow.com/questions/1031042/scalas-existential-types Java: – Type erasure and raw types – “?” generic wildcard Scala © Normation 2010 - 12
  • 13. 6. Syntactic sugar for existential type And in pattern matching © Normation 2010 - 13
  • 14. And some more _ with an other char 1) Accessors in tuples • ("foo", "bar")._2  // getter for “bar” 2) _* In repeated parameter (Java 1.5 varargs) • String.format("one: %s two: %s", "1" , "2") • String.format("one: %s two: %s", Seq("1","2"):_*) In XML pattern matching • See Scala XML book http://www.scala­lang.org/node/131  In pattern matching, as sequence wildcard • Search for UnapplySeq documentation 3) In identifier name ending with an operator • ex: “query?” not valide name, use “query_?” 4) In setter name • _= http://stackoverflow.com/questions/1392862/scala-overriding-a-non-abstract-def-with-a-var/1393389#1393389 © Normation 2010 - 14
  • 15. Q&A Thanks ! © Normation 2010 15