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

Rubyist fib(n) with ternary operator #9

Closed
jaxn opened this issue Oct 4, 2016 · 1 comment
Closed

Rubyist fib(n) with ternary operator #9

jaxn opened this issue Oct 4, 2016 · 1 comment

Comments

@jaxn
Copy link
Contributor

jaxn commented Oct 4, 2016

As someone who writes Ruby regularly, I felt your fib(n) seemed awkward.

fib(n)
  n < 2 ? n : fib(n-1) + fib(n-2)
end
alias :fibonacci :fib

I think that example is true to the ruby style as well as true to your argument.

@mjhea0
Copy link
Owner

mjhea0 commented Oct 4, 2016

Looks good. Want to issue a PR?

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