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

Rprogramming, Functions, mad_libs code accepted with bad results #273

Closed
nmcgarry opened this issue Mar 11, 2015 · 4 comments
Closed

Rprogramming, Functions, mad_libs code accepted with bad results #273

nmcgarry opened this issue Mar 11, 2015 · 4 comments

Comments

@nmcgarry
Copy link

I'm trying to complete the Functions lesson for Rprogramming and although my mad_libs function code was accepted as "correct" by swirl and I'm able to move on, the print out only ever has blanks for the arguments. Below is my code and print out

mad_libs <- function(...){

Do your argument unpacking here!

args <- list(...)
place <- args[["place"]]
adjective <- args[["adjective"]]
noun <- args[["noun"]]

Don't modify any code below this comment.

Notice the variables you'll need to create in order for the code below to

be functional!

paste("News from", place, "today where", adjective, "students took to the streets in protest of the new", noun, "being installed on campus.")
}

mad_libs("DC", "energetic", "statue")
[1] "News from today where students took to the streets in protest of the new being installed on campus."

@seankross
Copy link
Member

You're so close! Don't forget that you have to pass named arguments into the function in order to capture those arguments from args.

@TStas
Copy link

TStas commented Sep 16, 2015

Hello!

I had the same issue, and then succeeded when using:

mad_libs(place = 'Paris', adjective = 'sparkly', noun = 'fork')

However, I'm having trouble understanding why we are using a '...' here, since there are only 3 arguments/variables anyway. Any clarity would really be appreciated!

Thank you!

@seankross
Copy link
Member

Hi @TStas,

The purpose of this question is to demonstrate how ... works, that's all.

@TStas
Copy link

TStas commented Sep 16, 2015

Oh, thank you!

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

3 participants