Project

General

Profile

Actions

Bug #16140

closed

non-typed variable

Added by professeurx (Françoys Proulx) over 4 years ago. Updated over 4 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux-gnu]
[ruby-core:94768]

Description

I not sure if it's a bug. But maybe it is.

a =  2
puts a

a = "two"
puts a

=> 2
=> two

I was expecting it to produce an error. After all, Ruby is supposed to be a dynamically typed language. Clearly for variables, it's not the case. if it's not a bug, it is possibly an option to be added to the interpreter.

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Status changed from Open to Rejected

This is expected behavior. I'm not sure why you are expecting an error, this is how variables in most dynamically typed languages work. It is the feature that separates dynamically typed languages from statically typed languages.

Actions #2

Updated by sawa (Tsuyoshi Sawada) over 4 years ago

  • Description updated (diff)
Actions

Also available in: Atom PDF

Like0
Like0Like0