File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 4949"""
5050 @allowscalar ex...
5151 @disallowscalar ex...
52+ allowscalar(::Function, ...)
5253
5354Temporarily allow or disallow scalar iteration.
5455
@@ -77,6 +78,15 @@ macro disallowscalar(ex)
7778 end
7879end
7980
81+ @doc (@doc @allowscalar ) ->
82+ function allowscalar (f:: Base.Callable , allow:: Bool = true , warn:: Bool = false )
83+ prev = scalar_allowed[]
84+ allowscalar (allow, warn)
85+ ret = f ()
86+ scalar_allowed[] = prev
87+ ret
88+ end
89+
8090
8191# basic indexing
8292
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ function test_indexing(AT)
2424 @test x[1 ] == 3
2525 end
2626
27+ allowscalar () do
28+ x[1 ] = 4
29+ @test x[1 ] == 4
30+ end
31+
2732 @test_throws ErrorException x[1 ]
2833 @test_throws ErrorException x[1 ] = 1
2934
You can’t perform that action at this time.
0 commit comments