← Back to index
|
Original Bugzilla link
Bug 9867 – Map opIndex is not usable with immutable types
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-04-03T11:49:00Z
Last change time
2016-08-27T23:25:38Z
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0
by andrej.mitrovich — 2013-04-03T11:49:33Z
import std.algorithm; private immutable string[12] longMonthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; immutable shortMonthNames = map!(a => a[0..3])(longMonthNames[]); // L24 void main() { string jan = shortMonthNames[0]; } test.d(24): Error: mutable method test.MapResult!(__lambda2, immutable(char[])[]).MapResult.opIndex is not callable using a immutable object
Comment #1
by andrej.mitrovich — 2013-04-03T11:51:08Z
It seems like most methods in MapResult should be inout (or const? I never know..), except maybe popFront.
Comment #2
by andrej.mitrovich — 2016-08-27T23:25:38Z
Haha what?? I thought I could make a range immutable and consume it?!