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

Confused by this snippet code #69

Closed
lumiasaki opened this issue May 6, 2015 · 1 comment
Closed

Confused by this snippet code #69

lumiasaki opened this issue May 6, 2015 · 1 comment

Comments

@lumiasaki
Copy link

In ChartViewBase.swift file, these is a snippet code like this:

/// returns the x-value at the given index
public func getXValue(index: Int) -> String!
{
if (_data == nil || _data.xValCount <= index)
{
return nil;
}
else
{
return _data.xVals[index];
}
}

I am not good at swift but I'm confused about the function's return type: String!, obviously, it may return nil.

I hope what I'm saying is clear enough...thx

@danielgindi
Copy link
Collaborator

That question is suitable for a Swift forum, or Stackoverflow, or just reading the Swift manual by Apple!
But to make long story short, a String! is an optional String (nullable) that will unwrap automatically, avoiding the need to user the ? operator for reading its value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants