0
0
Rubyprogramming~10 mins

Module declaration syntax in Ruby - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a module named MyModule.

Ruby
module [1]
  # module content
end
Drag options to blanks, or click blank then click option'
AMyModule
Bmy_module
CModule
Dmodule
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase names for modules.
Using reserved words like 'module' as the module name.
2fill in blank
medium

Complete the code to define a method inside the module.

Ruby
module Greetings
  def self.[1]
    puts 'Hello!'
  end
end
Drag options to blanks, or click blank then click option'
Agreet
BSayHello
Chello
Dsay_hello
Attempts:
3 left
💡 Hint
Common Mistakes
Using capital letters in method names.
Using method names that are not descriptive.
3fill in blank
hard

Fix the error in the module declaration syntax.

Ruby
module [1]
  def greet
    puts 'Hi!'
  end
end
Drag options to blanks, or click blank then click option'
AGreetModule
BgreetModule
Cgreet_module
Dgreetmodule
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or snake_case for module names.
Using method names as module names.
4fill in blank
hard

Fill both blanks to create a module with a constant and a method.

Ruby
module [1]
  VERSION = '1.0'
  def self.[2]
    puts "Version: #{VERSION}"
  end
end
Drag options to blanks, or click blank then click option'
AAppInfo
Bshow_version
Cdisplay_version
Dapp_info
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase for module names.
Using capital letters in method names.
5fill in blank
hard

Fill all three blanks to define a nested module with a method.

Ruby
module [1]
  module [2]
    def self.[3]
      puts 'Nested module method'
    end
  end
end
Drag options to blanks, or click blank then click option'
AOuterModule
BInnerModule
Cnested_method
Dinner_module
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or snake_case for module names.
Using capital letters in method names.