Git Product home page Git Product logo

say-hello-ruby's Introduction

Say Hello

Objectives

  1. Build a method that can be called with an optional argument by defining that method with a default argument.

Instructions

You will build a method called say_hello. This method should accept the argument of a person's name. It then should print "Hello " with the name followed by an exclamation point (don't forget that space after the "Hello"). For instance:

# I call on the method, say_hello, and give it the string "Gabriela" 
say_hello("Gabriela")

# The method prints this text to the screen:
Hello Gabriela!

There is one more thing this method should do: if you call on this method and forget to give it the name of a person, it should just say, "Hello Ruby Programmer!". Use a default argument to accomplish this!

Steps

  1. Run learn test to see where you stand.
  • You probably got two NoMethodErrors. This means the test was looking for a method called say_hello but couldn't find it.
  1. Define the method in say_hello.rb
  • Run learn test again. Are you getting a different error? If you haven't seen this error, guess what it's trying to tell you then Google it with the word "ruby".
  1. Get all the tests to pass!

say-hello-ruby's People

Contributors

ahimmelstoss avatar annjohn avatar aviflombaum avatar fislabstest avatar fs-lms-test-bot avatar graciemcguire avatar ihollander avatar jmburges avatar kthffmn avatar markedwardmurray avatar maxwellbenton avatar msuzoagu avatar sarogers avatar sophiedebenedetto avatar timothylevi avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

say-hello-ruby's Issues

error : Repository not found

I have finished the lab and all tests are now passing. However when ever I try to push the file to github I keep on getting the following error:

ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I do not know how to fix this error and this is the first time to receive it. Please help.

Default Arguments

Hi!

I'm in session "Default Arguments" right now and I'm trying to solve the lab task.
The code of my program I wrote in say_hello.rb is:

def say_hello(name = "Ruby programmer")
puts "Hello #{name}!"
end
say_hello

When I run it without any arguments, it tells me:

Hello Ruby programmer!

However, everytime I run `Learn´, I get this message:

Failed examples: rspec ./spec/say_hello_spec.rb:10 # say_hello defaults to Ruby Programmer when no name is passed in

I can't see any mistakes, do you noticed anything wrong in my code?
I definitely saved my changes.

Receiving a warning when I try to fork this lesson

I just finished the Default Arguments lesson and moved on to this one - Say Hello
When I try to open it in my IDE I receive this warning
WARNING: You are attempting to open a lesson that is beyond your current lesson.

All lessons are marked finished under my Curriculum tab up to this one .

Minor Ambiguity in Spec About Default Value of Name

  it 'defaults to your name Ruby Programmer when no name is passed in' do
    expect($stdout).to receive(:puts).with("Hello Ruby Programmer!")
    say_hello()
  end

The it could be interpreted as their name, the current Ruby Programmer's name, as opposed to the literal string. Just going to take out the your name part and leave Ruby Programmer

Invalid Beyond Current Lesson warning

When forking this lesson to the Learn IDE I am alerted that it is beyond my current lesson and asked if I want to continue, but it is the lesson I am currently on (all previous lessons have been completed). I do not know if this is only happening in my case, or for all users.

WARNING: You are attempting to open a lesson that is beyond your current lesson.
Are you sure you want to continue? [Yn]:

screen shot 2017-03-07 at 7 10 34 pm

IDE gave the "you're doing a lesson ahead" warning

FYI:
In both the local IDE and browser IDE, before forking the lesson, the IDE gave the warning that I was doing a lesson ahead of where I am in the curriculum. But that's incorrect. I had completed prior lessons.

Learn App Will Not Open Current Lesson

Hello,

I skipped over some lessons on my Mac to see other topics to be covered and had this pop up message...

  • (We strongly encourage you to complete lessons in sequence, but you can jump ahead if you're sure you want to proceed. You can always come back and finish this lesson later) -

I was working on the "Introductory Default Arguments 1" lesson, but Learn will not go back to that topic/lab I started. So, again I skipped ahead to the last topic, hoping it'll start from the beginning and reset Learn, still no changes, it's stuck on the last lesson. Please, how can I resolve.

Kind Regards,
Lucy

Introductory Default Arguments I - Suggestion

I found that the instructions for this lab were rather nebulous and/or inexplicit. Perhaps this is because more is expected of us students with more exposure to Ruby methods and arguments and hand-holding is occurring less.

I think that this lab should reference objective 2 of the previous Methods and Arguments exercise because that exercise helped me get through this lab.

Consider this code:

    def arguments_and_local_variables(name)
      person = name
      "Hello " + person
    end

    arguments_and_local_variables("George R.R. Martin")
      #=> "Hello George R.R. Martin"

I found the above very useful in understanding the instructions in Introductory Default Arguments I because using the plus sign is a big part of creating a method that satisfies the lab's requirements (Introductory Default Arguments I) especially when you need your code to look like this to pass the lab:

def say_hello(name = "Ruby Programmer")
  puts "Hello " + name + "!"
end

(note the "+") Take a look and tell me what you think I would love to answer any questions.

Error pushing changes to Git

I have received an error pushing changes to git. I have been stuck on this for a while and would really appreciate some help. thank you!

ERROR: Permission to learn-co-students/say-hello-ruby-prework.git denied to krdiamond.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

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.