Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

咨询关于Now函数入参的问题(About the Now function parameter issue) #199

Closed
maliyan opened this issue Nov 13, 2023 · 1 comment
Closed
Labels
Question Indicates that an issue, pull request, or discussion needs more information

Comments

@maliyan
Copy link

maliyan commented Nov 13, 2023

Now函数的参数个数是可变数量的,但是,看Carbon.Now的实现,却是取最后一个值,这样定义的函数,对于调用者来说会不会产生误解?我的问题是,为什么要将参数定义成可变参数呢?
The number of parameters for the Now function is variable; however, in the implementation of Carbon.Now, it only takes the last value. Won't such a definition of the function lead to misunderstandings for the caller? My question is, why are the parameters defined as variable?

// Now returns a Carbon instance for now.
// 当前
func (c Carbon) Now(timezone ...string) Carbon {
	if len(timezone) > 0 {
		c.loc, c.Error = getLocationByTimezone(timezone[len(timezone)-1])
	}
....
}
@maliyan maliyan added the Question Indicates that an issue, pull request, or discussion needs more information label Nov 13, 2023
@gouguoyin
Copy link
Collaborator

In Now method, the time zone is not mandatory and can also be set through SetTimezone method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Indicates that an issue, pull request, or discussion needs more information
Projects
None yet
Development

No branches or pull requests

2 participants