Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

of

Scala dreaded underscore Slide 1 Scala dreaded underscore Slide 2 Scala dreaded underscore Slide 3 Scala dreaded underscore Slide 4 Scala dreaded underscore Slide 5 Scala dreaded underscore Slide 6 Scala dreaded underscore Slide 7 Scala dreaded underscore Slide 8 Scala dreaded underscore Slide 9 Scala dreaded underscore Slide 10 Scala dreaded underscore Slide 11 Scala dreaded underscore Slide 12 Scala dreaded underscore Slide 13 Scala dreaded underscore Slide 14 Scala dreaded underscore Slide 15
Upcoming SlideShare
카카오스토리 웹팀의 코드리뷰 경험
Next

124 Likes

Share

Scala dreaded underscore

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

Scala dreaded underscore

  1. 1. Scala dreaded _ François Armand
  2. 2. Too many use for _ ? © Normation 2010 - 2
  3. 3. Too many use for _ ? © Normation 2010 - 3
  4. 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. 5. 1. Import all Java “import *” © Normation 2010 - 5
  6. 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. 7. 3. Unused variables In higher order functions © Normation 2010 - 7
  8. 8. 3. Unused variables In pattern matching © Normation 2010 - 8
  9. 9. 4. Anonymous parameters In higher order functions © Normation 2010 - 9
  10. 10. 4. Anonymous parameters In partial functions © Normation 2010 - 10
  11. 11. 5. Don't import name in namespace © Normation 2010 - 11
  12. 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. 13. 6. Syntactic sugar for existential type And in pattern matching © Normation 2010 - 13
  14. 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. 15. Q&A Thanks ! © Normation 2010 15
  • coalash

    Feb. 24, 2021
  • kunhe2

    Jun. 14, 2020
  • RohiniBasu

    Jun. 5, 2020
  • mirkoperrone3

    Nov. 26, 2019
  • GarvineOh1

    Oct. 2, 2019
  • AdityaDeshpande66

    Sep. 26, 2019
  • georyders

    Jul. 26, 2019
  • deepaknebhwani

    Jun. 25, 2019
  • nag9s

    Feb. 11, 2019
  • eisenzhong

    Dec. 24, 2018
  • greister

    Oct. 22, 2018
  • BaaGiiShark

    Aug. 8, 2018
  • skeerthipati

    Aug. 6, 2018
  • YifanXing

    Jul. 4, 2018
  • YaoWANG80

    Jun. 20, 2018
  • PratapNaik

    Apr. 15, 2018
  • SupreethShankar1

    Mar. 1, 2018
  • exceldream

    Feb. 25, 2018
  • SangyeopLee7

    Feb. 2, 2018
  • cocos-x

    Dec. 13, 2017

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

Views

Total views

63,797

On Slideshare

0

From embeds

0

Number of embeds

12,842

Actions

Downloads

7

Shares

0

Comments

0

Likes

124

×