Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Moosphan
Android-Daily-Interview
Repository navigation
Code
Issues
232
(232)
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
More
items
2019-11-27:谈谈Kotlin中的Unit?它和Java中的void有什么区别?
#198
New issue
Copy link
New issue
Copy link
Open
Open
2019-11-27:谈谈Kotlin中的Unit?它和Java中的void有什么区别?
#198
Copy link
Labels
Kotlin
Description
Moosphan
Issue body actions
No description provided.
Reactions are currently unavailable
Activity
Moosphan
added
Kotlin
on Nov 28, 2019
feelschaotic commented
on Dec 24, 2019
feelschaotic
Last edited by
feelschaotic
More actions
同:
两者概念相似
异:
Unit 是一个类,继承自 Any 类,单例(目的在于函数返回 Unit 时避免分配内存)
正因为 Unit 是一个普通的对象(这里指用 object 关键字定义的单例类型),所以可以调用它的 toString() 方法:结果一定是 "Kotlin.Unit"(源代码写死了)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Metadata
Metadata
Assignees
No one assigned
Labels
Kotlin
Projects
No projects
Milestone
No milestone
Relationships
None yet
Development
No branches or pull requests
Issue actions
Open in GitHub Copilot app
You can’t perform that action at this time.
Activity
feelschaotic commentedon Dec 24, 2019
同:
异: