Search code examples
smalltalkpharo

Pharo: #( $H $e $l $l $o ).'Hello' has no example in Finder


When I go to the finder and select "Examples" then I can't figure out how to find a method that turns #( $H $e $l $l $o ). into 'Hello'. Nor does MethodFinder new findMethodsByExampleInput: #( $H $e $l $l $o ) andExpectedResult: 'Hello'. work.

know how to do it(*), but I want to know how to utilize the Finder.

I guess the Finder simply can't find it? Am I missing something?

(*) For example, one way to do it i: String newFrom: #( $H $e $l $l $o ).. Another way would be: #($H $e $l $l $o) inject: '' into: [ :acc :el | acc, (el asString) ]. (though I would not expect the second way to be found by the Finder)

enter image description here


Solution

  • If you think about it like adding a collection of characters to a string rather than converting a collection to a string you can search for:

    '' . #( $H $e $l $l $o ) . 'Hello'
    

    in the Finder and you will get the results:

    #( $H $e $l $l $o ) joinUsing: '' -> 'Hello'
    '' , #( $H $e $l $l $o ) -> 'Hello'
    '' join: #( $H $e $l $l $o ) -> 'Hello'