A version selector on Try Opal would be amazingly helpful.
In this case I just know that making the second parameter true made something work in 0.11 that had worked in 0.10. I don't know which one the bug is in though, just because it worked before doesn't mean it was working as intended.
@elia i think there is a bug in js inlining, sometimes not generating a necessary return
example opal-active support String.camelize
non-working, generated by 0.11:
return (Opal.defn(self, '$camelize', TMP_String_camelize_2 = function $$camelize(first_letter) {
var self = this;
if (first_letter == null) {
first_letter = "upper";
}
self.$underscore().replace(/(^|_)([^_]+)/g, function(match, pre, word, index) {
var capitalize = first_letter === "upper" || index > 0;
return capitalize ? word.substr(0,1).toUpperCase()+word.substr(1) : word;
})
manual workaround:
return (Opal.defn(self, '$camelize', TMP_String_camelize_2 = function $$camelize(first_letter) {
var self = this;
if (first_letter == null) {
first_letter = "upper";
}
return self.$underscore().replace(/(^|_)([^_]+)/g, function(match, pre, word, index) {
var capitalize = first_letter === "upper" || index > 0;
return capitalize ? word.substr(0,1).toUpperCase()+word.substr(1) : word;
})