当前位置:网站首页>I stepped on a foundation pit today
I stepped on a foundation pit today
2022-07-04 02:25:00 【Programming samadhi】

introduction
I wonder if you have such an experience : It's wrong to suddenly find out that you have a deep-rooted view for a long time ?
I stepped on a pit today : I always remember in my impression setInterval After definition, it will Execute now Once inside the logic , So when implementing the logic in the figure below , I will take the second step (” Execute the logic immediately a“) It's not necessary , This province has brought me a bug, Khan, ~

It's out bug, We need to remedy , Don't lose your attitude !
Bronze grade
Speaking of the simplest fix , That's the method we often use , The code is as follows :
Yes , It's so simple and plain !
Diamond grade
Since it's diamond grade , Then you have to play some tricks , Otherwise, it will be useless .
In fact, there is a hidden danger in the above bronze level implementation : It cannot be ensured that there is only one timer executing this logic at the same time . Then let's encapsulate :
Xingyao class
Use the objective function to return the objective function itself .
Um. , The code style is a little higher .
King level
Since it needs to be executed immediately , Then why not use self executing functions ?
Although the logic is the same as above , But I don't know why it's a little tall ,-
Conclusion
In fact, I still don't understand why I have such a wrong memory , And no correction has been found for so long .
It's not terrible to make mistakes , The terrible thing is that you don't realize you've made a mistake !
It takes a good blacksmith to make steel. , Don't look at how big others' implementation methods are , In fact, it is the result of some reasonable combination of basic knowledge , As long as you have a good foundation , Even in the face of a simple piece of code, you can play a different trick !
- ~
- The end of this paper , Thank you for reading !
~
Learn interesting knowledge , Make interesting friends , Create interesting souls !
Hello everyone , I am a 〖 The samadhi of programming 〗 The author of Hermit King , My official account is 『 The samadhi of programming 』, Welcome to your attention , I hope you can give me more advice !
边栏推荐
- What is the intelligent monitoring system of sewage lifting pump station and does it play a big role
- Jerry's modification setting status [chapter]
- Gee import SHP data - crop image
- Keep an IT training diary 055- moral bitch
- What is the student party's Bluetooth headset recommendation? Student party easy to use Bluetooth headset recommended
- A. Min Max Swap
- Global and Chinese market of handheld melanoma scanners 2022-2028: Research Report on technology, participants, trends, market size and share
- How to subcontract uniapp and applet, detailed steps (illustration) # yyds dry goods inventory #
- MySQL workbench use
- LV1 tire pressure monitoring
猜你喜欢
![Jerry's synchronous weather information to equipment [chapter]](/img/a9/e09bbf62161ea8ba60b0fce3fb5f89.jpg)
Jerry's synchronous weather information to equipment [chapter]

Introduction to graphics: graphic painting (I)

ZABBIX API pulls the values of all hosts of a monitoring item and saves them in Excel
![Measurement fitting based on Halcon learning [4] measure_ arc. Hdev routine](/img/3a/cf6285ae1c01bda42874eeca9fe5b1.jpg)
Measurement fitting based on Halcon learning [4] measure_ arc. Hdev routine

Will the memory of ParticleSystem be affected by maxparticles

Write the first CUDA program

Bacteriostatic circle scanning correction template

Problems and solutions of several concurrent scenarios of redis

Applet graduation project is based on wechat classroom laboratory reservation applet graduation project opening report function reference

Solve the problem that the tabbar navigation at the bottom of vantui does not correspond to the page (window.loading.hash)
随机推荐
Méthode de calcul de la connexion MSSQL de la carte esp32c3
Yyds dry goods inventory it's not easy to say I love you | use the minimum web API to upload files
Redis transaction
Ai aide à la recherche de plagiat dans le design artistique! L'équipe du professeur Liu Fang a été embauchée par ACM mm, une conférence multimédia de haut niveau.
PTA tiantisai l1-079 tiantisai's kindness (20 points) detailed explanation
The difference between lambda expressions and anonymous inner classes
When the watch system of Jerry's is abnormal, it is used to restore the system [chapter]
Take you to master the formatter of visual studio code
String: LV1 eat hot pot
中電資訊-信貸業務數字化轉型如何從星空到指尖?
MySQL advanced (Advanced) SQL statement (I)
Buuctf QR code
Kiss number + close contact problem
false sharing
Pytoch residual network RESNET
2022 new examination questions for safety management personnel of hazardous chemical business units and certificate examination for safety management personnel of hazardous chemical business units
Format character%* s
在尋求人類智能AI的過程中,Meta將賭注押向了自監督學習
Career development direction
[Yugong series] February 2022 attack and defense world advanced question misc-83 (QR easy)