Project

General

Profile

Actions

Bug #12499

closed

case statement requires keyword "then" in windows

Added by KenAbramson (Ken Abramson) almost 8 years ago. Updated almost 8 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32]
[ruby-core:76056]

Description

the following example code does not compile on Windows
if you replace ":" with "then" it does compile
if you leave out "then" it does not compile

The Book of Ruby - http://www.sapphiresteel.com

def showDay( i )
	case( i )
		when 1 : puts("It's Monday" )
		when 2 : puts("It's Tuesday" )
		when 3 : puts("It's Wednesday" )
		when 4 : puts("It's Thursday" )
		when 5 : puts("It's Friday" )
		when (6..7) : puts( "Yippee! It's the weekend! " )
		else puts( "That's not a real day!" )
	end
end


for i in 1..8 do
	showDay( i )
end

Updated by normalperson (Eric Wong) almost 8 years ago

wrote:

if you replace ":" with "then" it does compile
if you leave out "then" it does not compile

This is a Ruby 1.9+ change. "then" is required after "when";
':' is no longer supported after "when"

Updated by usa (Usaku NAKAMURA) almost 8 years ago

  • Status changed from Open to Rejected

Updated by usa (Usaku NAKAMURA) almost 8 years ago

You can also use ; instead of then.

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

  • Description updated (diff)

: after when had never been an official spec.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0