# Syntax error for a case within a module

**URL:** <https://www.ruby-forum.com/t/syntax-error-for-a-case-within-a-module/124116>\
**Category:** Ruby\
**Created:** [December 24, 2007, 11:20pm UTC](https://www.ruby-forum.com/t/syntax-error-for-a-case-within-a-module/124116 "2007-12-24T23:20:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [December 24, 2007, 11:20pm UTC](https://www.ruby-forum.com/t/syntax-error-for-a-case-within-a-module/124116/1 "2007-12-24T23:20:03Z")

</div>

For the project at [http://code.google.com/p/dwemthys/source](http://code.google.com/p/dwemthys/source), I want to  
use this module to instantiate a random Creature. Maybe a Dragon, maybe  
a GreenDragon, maybe an IndustrialRaverMonkey or something else 🙂

I’ve done something similar in the past, but now I seem to have a syntax  
error. Normally I would “return Dragon” or similar, but for now just  
want to get the syntax squared away:

thufir@arrakis ~/Desktop/dwemthys $  
thufir@arrakis ~/Desktop/dwemthys $  
thufir@arrakis ~/Desktop/dwemthys $ ruby instantiate.rb  
instantiate.rb:16: syntax error, unexpected $end, expecting kEND  
thufir@arrakis ~/Desktop/dwemthys $  
thufir@arrakis ~/Desktop/dwemthys $ cat instantiate.rb  
require ‘dragon’

module Instantiate

def makeCreature.randomCreature()

```
    creatureType=Kernel.rand(0)

    case creatureType
    when 0
            return 0
    when 1
            return 1
    end #case

```

end #makeCreature

thufir@arrakis ~/Desktop/dwemthys $

thanks,

Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [December 24, 2007, 11:46pm UTC](https://www.ruby-forum.com/t/syntax-error-for-a-case-within-a-module/124116/2 "2007-12-24T23:46:23Z")

</div>

On Dec 24, 2007, at 14:19 , Thufir wrote:

> module Instantiate
> 
> def makeCreature.randomCreature()

if you indented properly you’d SEE your problem.

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [December 24, 2007, 11:52pm UTC](https://www.ruby-forum.com/t/syntax-error-for-a-case-within-a-module/124116/3 "2007-12-24T23:52:13Z")

</div>

On Tue, 25 Dec 2007 07:45:16 +0900, Ryan D. wrote:

> On Dec 24, 2007, at 14:19 , Thufir wrote:
> 
> > module Instantiate
> > 
> > def makeCreature.randomCreature()
> 
> if you indented properly you’d SEE your problem.

Yup, thanks, I changed the name of the file but neglected to change the  
name of the module.

Thanks,

Thufir
