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

indexing gotcha #19

Open
davharris opened this issue Mar 27, 2015 · 0 comments
Open

indexing gotcha #19

davharris opened this issue Mar 27, 2015 · 0 comments

Comments

@davharris
Copy link

This burned me a few months back.

f = function(x){
x
}

f() # Throws error: x is missing

g = function(x){
letters[x]
}

g(1) # Returns the first element of letters
g() # Doesn't throw error, returns ALL elements of letters 

Hadley Wickham pointed out that g(x) is doing helpfully letters[], which is different from letters[NULL].

ಠ_ಠ

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

1 participant