Coder Social home page Coder Social logo

assansav / programming-univbasics-3-methods-default-values-lab-online-web-prework Goto Github PK

View Code? Open in Web Editor NEW

This project forked from learn-co-students/programming-univbasics-3-methods-default-values-lab-online-web-prework

0.0 1.0 0.0 17 KB

License: Other

Ruby 100.00%

programming-univbasics-3-methods-default-values-lab-online-web-prework's Introduction

Meal Choice Lab

Learning Goals

  • Define a method that takes in required and optional arguments
  • Use puts to output a string
  • Define a return value

Introduction

We've demonstrated the basics of defining methods, printing output, and returning values. Let's combine the concepts we've shown you to create a "Meal Choice" in our Ruby program.

Define a Method that Takes in Required and Optional Arguments

We're attending a wedding and the newlyweds-to-be want to know what types of food they should provide at the banquet. Define a method named meal_choice that has three parameters:

  • Two required parameters for vegetables. Ex: veg1 and veg2
  • And an optional parameter for protein with a default value of meat

You should write your code in the file lib/meal_choice.rb.

Use puts to Output a String

Whether you're omnivorous, vegetarian, or vegan, you're going to be eating a nutritious meal!

  • First, in the body of your method, have the program puts "What a nutritious meal!"
  • Next, let's also have it puts "A plate of #{protein} with #{veg1} and #{veg2}." so that you can also see what you've ordered.

Top Tip: Remember, that puts has a return value of nil, so we need to give our method an explicit return value.

Define a Return Value

The hosts are going the meal information to keep track of what everyone is eating, so make sure the return value includes the three food items you've chosen by returning: "A plate of #{protein} with #{veg1} and #{veg2}."

Note: An explicit or implicit return can be used.

Conclusion

You're all set! You've successfully written a series of Ruby methods utilizing all of the various Ruby basics we've discuss thus far. Now, we'll teach you about scope, and how information can be passed around to different methods.

programming-univbasics-3-methods-default-values-lab-online-web-prework's People

Contributors

assansav avatar sgharms avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.