File: variables.rb

package info (click to toggle)
tree-sitter-ruby 0.23.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,780 kB
  • sloc: ansic: 472,675; javascript: 1,093; lisp: 190; makefile: 101; python: 88; ruby: 56; cpp: 14; sh: 9
file content (48 lines) | stat: -rw-r--r-- 1,222 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
one = 1
# <- variable

def two()
  three = one
  # ^ variable
  #        ^ function.method

  four = three
  # ^ variable
  #       ^ variable

  four.each do |i|
    puts i, three, five
    #    ^ variable.parameter
    #        ^ variable (because blocks are closures)
    #               ^ function.method
  end

  four.each do |(a, b), c: d, e = f|
    #            ^ variable.parameter
    #               ^ variable.parameter
    #                   ^ variable.parameter
    #                      ^ function.method
    #                         ^ variable.parameter
    #                             ^ function.method
    puts a, b, c, d, e, f
    #    ^ variable.parameter
    #       ^ variable.parameter
    #          ^ variable.parameter
    #             ^ function.method
    #                ^ variable.parameter
    #                   ^ function.method
  end

  five ||= 1
  # ^ variable

  six -> (seven) { eight(seven, five) }
  # ^ function.method
  #        ^ variable.parameter
  #                 ^ function.method
  #                      ^ variable.parameter
  #                              ^ variable

  seven
  # ^ function.method (because the `seven` above was in the scope of the lambda)
end