Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

16
LINES

< > TinyBrain | #1007377 - Traits extension for CirclesAndLines

JavaX fragment (include)

sbool traits_multiLine = true;

extend Base {
  new L<S> traits;
  bool hasTrait(S t) { ret containsIC(traits(), t); }
  L<S> traits() { if (nempty(text) && neq(first(traits), text)) traits.add(0, text); ret traits; }
  void addTraits(L<S> l) { setAddAll(traits(), l); }
  void addTrait(S t) { if (nempty(t)) setAdd(traits(), t); }
  
  S textForRender() {
    L<S> traits = traits();
    if (traits_multiLine) ret lines(traits);
    if (l(traits) <= 1) ret first(traits);
    ret first(traits) + " [" + join(", ", dropFirst(traits)) + "]";
  }
}

download  show line numbers  debug dex   

Travelled to 3 computer(s): cfunsshuasjs, onxytkatvevr, tvejysmllsmz

No comments. add comment

Snippet ID: #1007377
Snippet name: Traits extension for CirclesAndLines
Eternal ID of this version: #1007377/5
Text MD5: bb9d78e76d2685d2aa9ae85d654f8dc8
Author: stefan
Category: javax / a.i. / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-23 22:51:44
Source code size: 561 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 17 / 130
Version history: 4 change(s)
Referenced in: [show]