Giter Club home page Giter Club logo

rubyist.new's People

Contributors

bensie avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rubyist.new's Issues

Week 3 Exercise

Here is my solution to yesterday's exercise:
https://gist.github.com/1014564

I want to clarify something that came up last night. Take the following example:

class Address
  def initialize(options = {})
    @street = options[:street]
  end
end

Keep in mind that whenever there is an "=" as part of an argument list, it means that we're setting a default. In this case, if we initialize a new object without passing any arguments to Address.new(), the variable options will be set as any empty hash in the initializer. This in no way says that the options argument must be a hash.

Let's say we skip setting the default value here:

class Address
  def initialize(options)
    @street = options[:street]
  end
end

In this case, options becomes a required argument and there is no default value. It could still very well be a hash, but we're just not providing a default.

In either case, options can be passed to Address.new as any type of object (string, integer, array, etc), but we're expecting a hash and operating under the assumption that we'll be getting a hash.

Feel free to post any questions here.

@tapatio, @jkussmann, @weblife, @CreamyGoodness, @derekwrobel

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.