当前位置:网站首页>Function simplification principle: save if you can
Function simplification principle: save if you can
2022-06-30 09:26:00 【Orangejuicer】
The principle of simplifying functions : Able to save and save
return It can be omitted ,Scala The last line of the function body is used as the return value
If the body of a function has only one line of code , You can omit curly braces
If the return value type can be inferred , Then you can omit (: Omit with return value type )
If there is return, The return value type cannot be omitted , Must specify
If the function explicitly states unit, So even if you use return Keywords don't work either
Scala If no return value type is expected , You can omit the equal sign
If the function has no parameters , But a list of parameters is declared , So when calling , parentheses , Yes, but not
If the function doesn't have a parameter list , Then brackets can be omitted , Parentheses must be omitted when calling
If you don't care about the name , It's just about logical processing , So the function name (def) It can be omitted
边栏推荐
- [paid promotion] collection of frequently asked questions, FAQ of recommended list
- Opencv learning notes-day9 opencv's own color table operation (colormap coloraptypes enumeration data types and applycolormap() pseudo color function)
- Flink sql -- No factory implements ‘org. apache. flink. table. delegation. ExecutorFactory‘.
- Duplicate entry '2' for key 'primary appears in JPA‘
- Experience of an acmer
- Application of hongruan face recognition
- Tclistener server and tcpclient client use -- socket listening server and socketclient use
- Bottomsheetbehavior principle of realizing the home page effect of Gaode map
- Sort (simple description)
- Rew acoustic test (V): equipment required for test
猜你喜欢
Opencv learning notes -day8 (keyboard typing (waitkey()); Wait for typing) action: triggers some action when the appropriate character is typed using the keyboard)
Express file upload
Deeply understand the working principle of kotlin collaboration suspend (beginners can also understand it)
ES6 learning path (II) let & const
Express get request
Using appbarlayout to realize secondary ceiling function
Wechat development tool (applet)
12. problem set: process, thread and JNI architecture
Express の post request
The elegant combination of walle and Jianbao
随机推荐
[JPEG] how to compile JPEG turbo library files on different platforms
Opencv learning notes-day14 drawing of image geometry (rect class rotatedrect class, rectangle drawing rectangle circle drawing circular function line drawing line function ellipse drawing elliptic fu
Deep Learning with Pytorch- neural network
Express file download
Talk about how the kotlin collaboration process establishes structured concurrency
Opencv learning notes-day5 (arithmetic operation of image pixels, add() addition function, subtract() subtraction function, divide() division function, multiply() multiplication function
List set export excel table
Tclistener server and tcpclient client use -- socket listening server and socketclient use
POJ 1753 flip game (DFS 𞓜 bit operation)
Wechat development tool (applet)
Express get request
Deeply understand the working principle of kotlin collaboration suspend (beginners can also understand it)
Rew acoustic test (VI): signal and measurement
What are the SQL add / delete / modify queries?
Esp32 things (3): overview of the overall system design
Express - static resource request
Introduction to the runner of mmcv
Handwriting sorter component
I once met a girl whom I most wanted to take care of all my life. Later... No later
Guilin robust medical acquired 100% equity of Guilin Latex to fill the blank of latex product line