PRE-RFC: Add getters and setters for global variables #1608
sampersand
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
should be $.: Integer
$.=: int
$0: String
$0=: string
$-F: String | Regexp | nil
$-F=: string | Regexp | nil to match |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is quite niche, so it's probably not super important but...
Global variables in Ruby have "getters" and "setters". For user-defined global variables, the type of the global is the same when both getting and setting. However, quite a few builtin globals (
$.
,$-F
,$0
, etc.) can be assigned more permissive types, and convert them. (For example,$.
can be assignedint
s, but converts them internally.)I propose "global variable setter and getter" syntax:
If no setter is supplied, the global variable is assumed to have both the same getter and setter.
Beta Was this translation helpful? Give feedback.
All reactions