No internet connection
  1. Home

Comments for http://horstmann.com/unblog/2018-06-01/index.html

By System @system
    2018-06-05 14:34:49.990Z
    • 1 comments
    1. K
      @KajMagnus
        2018-06-05 14:34:51.102Z

        Wow first I thought this: "enclose the string in a sequence of backticks that is longer than the longest sequence inside" was really clever, ... until I saw this the example:

        "`" + ``alert("JavaScript")```
        

        which I'm not sure if I understand correctly :- P
        not really what one wants one's colleagues to spend their time thinking about.

        I like Scala's approach where one can define one's own x""" .... """ string prefixes, and have them be like Raw Strings or Blending In strings or whatever :- ) I created one named i which is supposed to mean "indented string", and it trims all spaces up to the | on each line. (Source here.) Here's an example, namely some inline Yaml for ElasticSearch:

          val IndexSettings = i"""
            |number_of_shards: 5
            |number_of_replicas: 1
            |analysis:
            |  analyzer:
            |    HtmlSnowball:
            |      type: custom
            |      tokenizer: standard
            |      filter: [standard, lowercase, stop, snowball]
            |      char_filter: [HtmlStrip]
            |  char_filter :
            |    HtmlStrip :
            |      type : html_strip
            |#     escaped_tags : [xxx, yyy]  -- what's this?
            |#     read_ahead : 1024        -- what's this?
            |"""
        

        ( & no need to wonder about tabs & spaces :- ))